Sign in to follow this  
Followers 0
tinjaw

Display One Date Format & Use Another For Date Math?

5 posts in this topic

#1 ·  Posted (edited)

Is there a way to display a date in one format and use another format for use with _DateDiff()?

I am using a Date Picker GUI control. The default Date Style is $DTS_LONGDATEFORMAT (i.e. Friday, April 19, 1988). This is the way I would like it displayed to the user. However, I wish to use that date, along with the current date, retrieved with _NowCalcDate(), in _DateDiff() to obtain the number of days between the two dates. If I understand the docos correctly, to be used in _DateDiff() the date needs to be in YYYY/MM/DD format - as it is returned by _NowCalcDate().

Since the style of the control is $DTS_LONGDATEFORMAT, if I use GUICtrlRead($MyDatePicker) I will not get the date back in a format that I can use with _DateDiff.

Anything available in v2.3.10 for this? If not, any suggestions on how I go about this?

thanx

Edited by tinjaw

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Just return it in this format from the date selection: YYYY/MM/DD[HH:MM:SS] and store a second copy.

#Include <date.au3>

;Return value from date selection
$unformattedDate = "2008/01/30[00:00:00]"

$formattedDate = _DateTimeFormat ($unformattedDate, 1)
Edited by weaponx

Share this post


Link to post
Share on other sites

Just return it in this format from the date selection: YYYY/MM/DD[HH:MM:SS]

The date picker displays the date to the left of the calendar based on the $style. That is where I want it displayed as DayOfTheWeek, Month Day, Year. So if I set $style = "yyyy/MM/dd HH:mm:s" then that is how it will be displayed. Hence my problem.

Share this post


Link to post
Share on other sites

The date picker displays the date to the left of the calendar based on the $style. That is where I want it displayed as DayOfTheWeek, Month Day, Year. So if I set $style = "yyyy/MM/dd HH:mm:s" then that is how it will be displayed. Hence my problem.

Meal Planner is one example where I know the date format is played with so it might be worth looking at it.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I got lucky and found what I needed in another forum posting. It is a function to convert long format dates to short format dates.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0