From Team Developer SqlWindows Wiki
Revision as of 13:54, 12 September 2008 by (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page covers datetime datatype tips & tricks.


Pointer.pngHow to strip elements from a DateTime

The next function is able to strip certain parts from a datetime.
So with this it is possible to construct a new datetime value with only the wanted elements.
Milliseconds are allways stripped.

Function: PALDateConstruct
      Date/Time: pdtDateTime
      Boolean: pbYearMonthDays
      Boolean: pbHoursMinutes
      Boolean: pbSeconds
   Local variables
      Number: nYear
      Number: nMonth
      Number: nDay
      Number: nHour
      Number: nMinute
      Number: nSecond
      If pbYearMonthDays
         Set nYear   = SalDateYear( pdtDateTime )
         Set nMonth  = SalDateMonth( pdtDateTime )
         Set nDay    = SalDateDay( pdtDateTime )
      If pbHoursMinutes
         Set nHour   = SalDateHour( pdtDateTime )
         Set nMinute = SalDateMinute( pdtDateTime )
      If pbSeconds
         Set nSecond = SalDateSecond( pdtDateTime )
      Return SalDateConstruct( nYear, nMonth, nDay, nHour, nMinute, nSecond )

So to strip of the seconds from the current datetime

   dtTodayNoSeconds = PALDateConstruct( SalDateCurrent( ), TRUE, TRUE, FALSE )

Pointer.pngEnter new tip title here

Enter new tip description here