Difference between revisions of "DateTime"

From Team Developer SqlWindows Wiki
Jump to: navigation, search
m
Line 1: Line 1:
'''This page covers datetime datatype tips & tricks.'''
+
{{PageHeader|DateTime datatype}}
 +
 
  
 
__TOC__
 
__TOC__
<br>
+
 
  
 
<!------------------------------------------------------------------------------------------------------------------------------>
 
<!------------------------------------------------------------------------------------------------------------------------------>
 
{{TipHeader|How to strip elements from a DateTime}}
 
{{TipHeader|How to strip elements from a DateTime}}
  
The next function is able to strip certain parts from a datetime.<br>
+
The next function is able to strip certain parts from a DateTime.<br>
So with this it is possible to construct a new datetime value with only the wanted elements.<br>
+
So with this it is possible to construct a new DateTime value with only the wanted elements.<br>
Milliseconds are allways stripped.
+
Milliseconds are always stripped.
 
<pre>
 
<pre>
 
Function: PALDateConstruct
 
Function: PALDateConstruct
Line 38: Line 39:
 
       Return SalDateConstruct( nYear, nMonth, nDay, nHour, nMinute, nSecond )
 
       Return SalDateConstruct( nYear, nMonth, nDay, nHour, nMinute, nSecond )
 
</pre>
 
</pre>
So to strip of the seconds from the current datetime
+
So to strip of the seconds from the current DateTime
 
<pre>
 
<pre>
 
   dtTodayNoSeconds = PALDateConstruct( SalDateCurrent( ), TRUE, TRUE, FALSE )
 
   dtTodayNoSeconds = PALDateConstruct( SalDateCurrent( ), TRUE, TRUE, FALSE )
 
</pre>
 
</pre>
 
 
<!------------------------------------------------------------------------------------------------------------------------------>
 
{{TipHeader|Enter new tip title here}}
 
Enter new tip description here
 
  
  
  
 
[[Category:Datatypes]]
 
[[Category:Datatypes]]

Revision as of 08:11, 15 July 2013

DateTime datatype


Contents


Pointer2.png How to strip elements from a DateTime Pointer.png

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 always stripped.

Function: PALDateConstruct
   Returns
      Date/Time:
   Parameters
      Date/Time: pdtDateTime
      Boolean: pbYearMonthDays
      Boolean: pbHoursMinutes
      Boolean: pbSeconds
   Local variables
      Number: nYear
      Number: nMonth
      Number: nDay
      Number: nHour
      Number: nMinute
      Number: nSecond
   Actions
      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 )