Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Proper syntax for universal date
Message
From
10/04/2003 08:45:42
 
 
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00775886
Message ID:
00775968
Views:
14
>Should be OK, although you've refered to Month() at the start of the Backend conversion and DAY() twice in the remainder of the expression.
>
>You could just use DTOS() though.
>
>And do you need to refer to the .000 part of the time??
>
>If using this for comparisons with SQL, also remember that you don't have a Date only field in SQL, and you may need to add 00:00:00.000 to the end of the date field.

Thanks, here's a revised version.
* Return a date in a universal format
* expD1 Date
* expL1 Pass .T. when generating for a backend
FUNCTION DateUniversal
PARAMETERS tdDate,tlBackend
LOCAL lcDate
lcDate=''

* Client server
IF tlBackend
   lcDate=lcDate+"'"
   lcDate=lcDate+PADL(MONTH(tdDate),2,'0')+'/'+PADL(DAY(tdDate),2,'0')+'/'+ALLTRIM(STR(YEAR(tdDate)))
   lcDate=lcDate+' '+PADL(HOUR(tdDate),2,'0')+':'+PADL(MINUTE(tdDate),2,'0')+':'+PADL(SEC(tdDate),2,'0')
   ELSE
   lcDate=lcDate+'{^'
   lcDate=lcDate+DTOS(tdDate)

   * If we have a date time
   IF TYPE('tdDate')='T'
      lcDate=lcDate+' '+PADL(HOUR(tdDate),2,'0')+':'+PADL(MINUTE(tdDate),2,'0')+':'+PADL(SEC(tdDate),2,'0')
   ENDIF

ENDIF

* Client server
IF tlBackend
   lcDate=lcDate+"'"
   ELSE
   lcDate=lcDate+'}'
ENDIF

RETURN lcDate
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform