Parse Date - Gets ISO Date format for use in DB's

Post specialized setup scripts you have created here.
K1pp3r
Posts: 7
Joined: Mon Oct 22, 2007 3:30 am
Location: Grimsby, UK

Parse Date - Gets ISO Date format for use in DB's

Postby K1pp3r » Thu Nov 01, 2007 2:58 pm

Although this is a bit simplistic it does overcome quite a serious issue when writing a date value to a sql table from an MS Script block.

When delivering product internationally the $DATE$ variable returns the date in the format of client computer (ie 10/1/2007 - US, 01/10/2007 - UK, 1.10.2007 - Germany). I never make assumptions with SQL Server, therefore the safest date format to use is ISO (2007/10/01), this script reads the date format and date seperator from the registry and then parses the $DATE$ variable setting a return variable with the ISO date value (in sthis case SQL_DB_DATE).

~InstallAware Clipboard Data~
~Comment~
~{E1C92BCB-4293-44B0-BA34-FD9F18F474C9}~
~~
~Set Variable~
~{3719987F-A989-41E9-A90D-C4D680D6F737}~
~SQL_DB_DATE$MYAH$MYAH$FALSE~
~$YEAR$/$MONTH$/$DAY$~
~End~
~{B9393914-4FC8-4E0D-8CB3-6F40D7BFC6B9}~
~Parse String~
~{507D38CC-E1ED-4BD4-A0E4-70033778798F}~
~$TEMP_DATE$~
~$DATE_SEPERATOR$~
~DAY~
~TEMP_DATE~
~0~
~TRUE~
~TRUE~
~Parse String~
~{56E591DF-6A68-4A9D-8620-B7C3DCED3E25}~
~$TEMP_DATE$~
~$DATE_SEPERATOR$~
~MONTH~
~TEMP_DATE~
~0~
~TRUE~
~TRUE~
~Parse String~
~{56CD283C-F2F7-4C33-B924-85AACCC7699D}~
~$DATE$~
~$DATE_SEPERATOR$~
~YEAR~
~TEMP_DATE~
~0~
~TRUE~
~TRUE~
~If~
~{41A6A509-E506-419D-9441-4A4670A18BBC}~
~DATE_FORMAT~
~0~
~2~
~FALSE~
~End~
~{4B39E1C9-0259-4A9D-92EE-C80D1B174D76}~
~Parse String~
~{768CE972-F198-4D7E-A125-7C52FB9E01DD}~
~$TEMP_DATE$~
~$DATE_SEPERATOR$~
~YEAR~
~TEMP_DATE~
~0~
~TRUE~
~TRUE~
~Parse String~
~{B95EFE82-6FB9-4FB2-9597-B72DF59D6749}~
~$TEMP_DATE$~
~$DATE_SEPERATOR$~
~MONTH~
~TEMP_DATE~
~0~
~TRUE~
~TRUE~
~Parse String~
~{FDA80FEB-259B-4F16-9D81-D28D56AFB50B}~
~$DATE$~
~$DATE_SEPERATOR$~
~DAY~
~TEMP_DATE~
~0~
~TRUE~
~TRUE~
~If~
~{079CCD3D-1685-4E01-B661-F4B12083BECE}~
~DATE_FORMAT~
~0~
~1~
~FALSE~
~End~
~{A4FB2074-85F6-473C-85DC-33C4BFB23FC9}~
~Parse String~
~{9D3B00D5-4C8F-4499-9154-2A5395CA4A40}~
~$TEMP_DATE$~
~$DATE_SEPERATOR$~
~YEAR~
~TEMP_DATE~
~0~
~TRUE~
~TRUE~
~Parse String~
~{534C264C-14E9-4B7D-A550-30C68469734A}~
~$TEMP_DATE$~
~$DATE_SEPERATOR$~
~DAY~
~TEMP_DATE~
~0~
~TRUE~
~TRUE~
~Parse String~
~{15A24F0B-9279-4522-86E8-508CFB9A7C99}~
~$DATE$~
~$DATE_SEPERATOR$~
~MONTH~
~TEMP_DATE~
~0~
~TRUE~
~TRUE~
~If~
~{4CAF17C4-F61E-4DA0-81E9-2013EFBDADAB}~
~DATE_FORMAT~
~0~
~0~
~FALSE~
~Set Variable~
~{21BE3DEF-B05E-41BF-B139-408728CEB274}~
~YEAR$MYAH$MYAH$FALSE~
~~
~Set Variable~
~{B7406E73-37DF-4851-AEFE-47366AA3CE54}~
~MONTH$MYAH$MYAH$FALSE~
~~
~Set Variable~
~{EDE68AAB-CDD0-4AFA-AA0E-87B326A39150}~
~DAY$MYAH$MYAH$FALSE~
~~
~Set Variable~
~{71E284F7-5BDC-4146-9667-5F6430D11352}~
~TEMP_DATE$MYAH$MYAH$FALSE~
~~
~Read Registry~
~{9D964D13-C02A-4A66-B53F-8957955D51AC}~
~DATE_SEPERATOR~
~1~
~Control Panel\\International~
~sDate~
~Read Registry~
~{2FA48E48-A67E-436D-B7CF-8FCB4EEC1F8A}~
~DATE_FORMAT~
~1~
~Control Panel\\International~
~iDate~
~Set Variable~
~{54ED1C68-D13C-489D-A8CB-27AABF0F9DE1}~
~DATE_SEPERATOR$MYAH$MYAH$FALSE~
~~
~Set Variable~
~{9A04310B-DAFE-437E-AD2B-294B53065DA8}~
~DATE_FORMAT$MYAH$MYAH$FALSE~
~~

As I said simplistic but I find it useful.

Regards

Return to “Sample Scripts”

Who is online

Users browsing this forum: No registered users and 20 guests