BartvanBeek Posted October 6, 2008 Share Posted October 6, 2008 Hi, I'm looking for a function to format each date to one format. Just one format: YYYY/MM/DD When i go into the function i don't know which format the date has, it can be: - DD-MM-YYYY - MM-DD-YYYY - YYYY-DD-MM - DD-MM-YYYY Is there a function to handle this? Link to comment Share on other sites More sharing options...
Andreik Posted October 6, 2008 Share Posted October 6, 2008 (edited) Hi,I'm looking for a function to format each date to one format.Just one format: YYYY/MM/DDWhen i go into the function i don't know which format the date has, it can be:- DD-MM-YYYY- MM-DD-YYYY- YYYY-DD-MM- DD-MM-YYYYIs there a function to handle this?_DateTimeFormat() but is need this format YYYY/MM/DD and is very hard to know where is DD-MM or MM-DD. Edited October 6, 2008 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Xenobiologist Posted October 6, 2008 Share Posted October 6, 2008 Hi, if you do not know then there is no chance. - DD-MM-YYYY - MM-DD-YYYY These two dates cannot not be interpretated by a script. You need to get that info from ... maybe the system. Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
BartvanBeek Posted October 6, 2008 Author Share Posted October 6, 2008 Is it realy unpossible??? A script with a date format DD-MM-YYYY can written in each script en runs on each PC with another date format. That's how to solve this issue? Link to comment Share on other sites More sharing options...
monoceres Posted October 6, 2008 Share Posted October 6, 2008 Is it realy unpossible???A script with a date format DD-MM-YYYY can written in each script en runs on each PC with another date format. That's how to solve this issue?Think about it.Lets say I provide your script with the following date:1990-05-06What format did I use? Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Xenobiologist Posted October 6, 2008 Share Posted October 6, 2008 Hi, depends on where are you going to use it. Maybe you can use a datepicker like GUICtrlCreateDate Where are you going to use the date? User interaction? Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
BartvanBeek Posted October 6, 2008 Author Share Posted October 6, 2008 Hi, depends on where are you going to use it. Maybe you can use a datepicker like GUICtrlCreateDate Where are you going to use the date? User interaction? Mega Yes, i want to filter on a date collumn in a listview. But the date collumn can have more date format. monoceres: I know what you mean. Is this an idea? Func _FormatDate($Date,$Sep = "/") $Now = _NowDate() $Now = StringReplace($Now,".",$Sep) $Now = StringReplace($Now,"\",$Sep) $Now = StringReplace($Now,"-",$Sep) $Now = StringReplace($Now," ",$Sep) $Part = StringSplit($Now,$Sep) $Date = StringReplace($Date,".",$Sep) $Date = StringReplace($Date,"\",$Sep) $Date = StringReplace($Date,"-",$Sep) $Date = StringReplace($Date," ",$Sep) $Part2 = StringSplit($Date,$Sep) $Part[1] = INT($Part[1]) $Part[2] = INT($Part[2]) $Part[3] = INT($Part[3]) Switch True Case $Part[1] = Int(@YEAR) AND $Part[2] = Int(@MON) AND $Part[3] = Int(@MDAY) ; Y M D Return _AddZero($Part2[1]) & $Sep & $Part2[2] & $Sep & $Part2[3] Case $Part[1] = Int(@YEAR) AND $Part[3] = Int(@MON) AND $Part[2] = Int(@MDAY) ; Y D M Return _AddZero($Part2[1]) & $Sep & $Part2[3] & $Sep & $Part2[2] Case $Part[3] = Int(@YEAR) AND $Part[2] = Int(@MON) AND $Part[1] = Int(@MDAY) ; D M Y Return _AddZero($Part2[3]) & $Sep & $Part2[2] & $Sep & $Part2[1] Case $Part[3] = Int(@YEAR) AND $Part[1] = Int(@MON) AND $Part[2] = Int(@MDAY) ; M D Y Return _AddZero($Part2[3]) & $Sep & $Part2[1] & $Sep & $Part2[2] Case Else MsgBox(48,$AppName,"Date cannot be formatted correctly.") Return "" EndSwitch EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now