Restored from previous forum. Originally posted by Shawn.
Hi.
It would be useful to have some built-in date functions like Year(), Month(), Day(), DateDiff(), DateAdd(), IsDate(), FormatDate(). Also some Time functions.
Could the FileSystem library be expanded to get file creation and modification dates and times?
Thanks.
Shawn
Date functions
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by freak.
Yes, would be good to implement for all OSes, but for Windows, it's
easy to do:
If you just want the year:
There's also wMonth, wDay, wDayOfWeek, wHour, wMinute, wSecond, wMilliseconds
in the Structure.
I don't know, what you mean by DateDiff(), DateAdd() and IsDate.
Maybe you could explain that a little more.
Timo
--
A debugged program is one for which you have not yet found the conditions that make it fail.
Edited by - freak on 31 July 2002 10:49:18
Yes, would be good to implement for all OSes, but for Windows, it's
easy to do:
Code: Select all
Procedure.s TIME()
GetLocalTime_(@systime.SYSTEMTIME)
ProcedureReturn Right("00"+Str(systime\wHour),2)+":"+Right("00"+Str(systime\wMinute),2)
EndProcedure
Procedure.s DATE()
GetLocalTime_(@systime.SYSTEMTIME)
ProcedureReturn Right("00"+Str(systime\wDay),2)+"."+Right("00"+Str(systime\wMonth),2)+"."+Right(Str(systime\wYear),2)
EndProcedure
Code: Select all
GetLocalTime_(@systime.SYSTEMTIME)
year = systime\wYear
in the Structure.
I don't know, what you mean by DateDiff(), DateAdd() and IsDate.
Maybe you could explain that a little more.
Timo
--
A debugged program is one for which you have not yet found the conditions that make it fail.
Edited by - freak on 31 July 2002 10:49:18
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Shawn.
Yes, the results you can get using GetLocalTime are easy. There is also a user library you can add to get results similar to these, but it would be nice to have them part of PB. This is the Wishlist right?
The others are similar to VB. Something like this:
I am sure there are others too.
Shawn
Yes, the results you can get using GetLocalTime are easy. There is also a user library you can add to get results similar to these, but it would be nice to have them part of PB. This is the Wishlist right?
The others are similar to VB. Something like this:
Code: Select all
DateDiff() would return the difference between two dates.
e.g. DateDiff("days", "01/15/02", "01/18/02") gives 2 (days)
DateDiff("years","01/15/02", "01/18/03") gives 3 (years)
DateAdd() Adds (or subtracts) an interval to a date
e.g. DateAdd("days", 2, "01/30/02") gives "02/01/02"
IsDate() Checks if the variable is a valid date.
e.g. IsDate("02/30/02") gives #FALSE
FormatDate() Formats the date into the format you need.
e.g. FormatDate("01/30/02","mmmm dd, yyyy") gives "January 30, 2002"
Now() gives the current date
Shawn
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
> IsDate() Checks if the variable is a valid date.
I made a procedure for this ages ago. Until it can be made an internal command,
you can use my procedure found here:
viewtopic.php?t=1468
PB - Registered PureBasic Coder
Edited by - PB on 31 July 2002 14:48:08
> IsDate() Checks if the variable is a valid date.
I made a procedure for this ages ago. Until it can be made an internal command,
you can use my procedure found here:
viewtopic.php?t=1468
PB - Registered PureBasic Coder
Edited by - PB on 31 July 2002 14:48:08
-
- Enthusiast
- Posts: 536
- Joined: Mon Feb 16, 2009 10:42 am
- Location: sweden
- Contact:
Re: Date functions
What happened to that Isdate - function? The link doesnt work any more!!
Anyway, found out its possible to do
debug ParseDate("%yyyy-%mm-%dd","1979-09-17")
debug ParseDate("%yyyy-%mm-%dd","1sdfsdf17")
First one will return a positive number while the second will return -1
Anyway, found out its possible to do
debug ParseDate("%yyyy-%mm-%dd","1979-09-17")
debug ParseDate("%yyyy-%mm-%dd","1sdfsdf17")
First one will return a positive number while the second will return -1