Proc to get datevalue from "21/02/2015", "23:59:59" params
Posted: Wed Oct 21, 2015 10:35 pm
Hi to all I have a sql db that i needed to add a new table from existing date and a time table in different formats ( "21/02/2015", "23:59:59" ) so i came up with this little Procedure so i can quickly run through the db and and create and add the new table from the existing. It might be useful to others so thought I`d share.
Zebuddi.
Zebuddi.

Code: Select all
Procedure.i GetLongDate(date.s, date_delimeter.s, time.s, time_delimeter.s)
Macro _mSF(string, index, delimeter)
Val(StringField(String, index, delimeter))
EndMacro
ProcedureReturn Date(_mSF(date,3,date_delimeter),_mSF(date,2,date_delimeter),_mSF(date,1,date_delimeter),_mSF(time,1,time_delimeter),_mSF(time,2,time_delimeter),_mSF(time,3,time_delimeter))
EndProcedure
Example:
nd = GetLongDate("21/02/2015", "/", "23:59:59", ":")
Debug nd
Debug FormatDate("%dd,%mm,%yyyy,%hh,%ii,%ss",nd )