Jump to content
Sign in to follow this  
PhilipG

GUIset Date?

Recommended Posts

PhilipG

I am trying to set a pre selected date into a Date control but it doesn't work. Al the help file says is that i should look under guisetdata, but in that part it doesn't say anything I can understand.

My code:

GUICtrlCreateLabel ( "Datum:", 10, 115, $widthCell)
$datum = GUICtrlCreateDate("", 10, 130, 150, 20);Create the datefield

GUICtrlSetData ($datum, $pre);Update the date field

at first the script loads the control. That part works.

Then you can select a date and save it into a database. The value stored is the one returned by GUICtrlRead command.

The stored value could then be re opened (to view the saved date)

Thats what doesn't work.

The $pre variable is the exact value that is stored in the database.

What should i do?

Share this post


Link to post
Share on other sites
PsaltyDS

Post the exact string you get from GuiCtrlRead() at the date control. The format of the output can be changed and is variable, but the input to set the date must always be "YYYY/MM/DD" format.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
PhilipG

A sweet!

Is there any way to chose that as the output but stil maintain the long name in the date?

Share this post


Link to post
Share on other sites
martin

A sweet!

Is there any way to chose that as the output but stil maintain the long name in the date?

$hDateDue = GUICtrlGetHandle($DateDue)
_GUICtrlDTP_SetFormat($hDateDue, "dd MM yyyy")

$somevar = GUICtrlRead($DateDue);now read in set format which we can use to write to it as well


_GUICtrlDTP_SetFormat($hDateDue, "dd MMMMM yyyy");set back to whatever

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
PhilipG

I have some wierd results when i'm trying that code snippet...

The code:

#Include <GuiDateTimePicker.au3>
#include <DateTimeConstants.au3>

GUICtrlCreateLabel ( "Datum:", 10, 115, $widthCell)
$datum = GUICtrlCreateDate("", 10, 130, 150, 20)

_GUICtrlDTP_SetFormat($datum, "yyyy mm dd")
    _SQLite_Exec($dbn,"INSERT INTO uppdrag (datum) VALUES (GUICtrlRead ($datum));"); sparar i databasen

When I run this code it provides a wierd error message It says something like:

"_WinAPI_OpenProcess:Priviliged: Access is denied"

If I comment ;_GUICtrlDTP_SetFormat($datum, "yyyy mm dd")

Then It works... so what is the problem with the

_GUICtrlDTP_SetFormat($datum, "yyyy mm dd") function?

Share this post


Link to post
Share on other sites
PhilipG

Never mind last post... I figured I missed the gethandle part My bad sorry

Share this post


Link to post
Share on other sites
MirnesC2

You can also use

@MSEC
 Milliseconds value of clock.  Range is 00 to 999 
@SEC
 Seconds value of clock.  Range is 00 to 59 
@MIN
 Minutes value of clock.  Range is 00 to 59
@HOUR
 Hours value of clock in 24-hour format.  Range is 00 to 23
@MDAY
 Current day of month.  Range is 01 to 31
@MON
 Current month.  Range is 01 to 12 
@YEAR
 Current four-digit year  
@WDAY
 Numeric day of week.  Range is 1 to 7 which corresponds to Sunday through Saturday.  
@YDAY
 Current day of year.  Range is 1 to 366 (or 365 if not a leap year)

$m = $MON
$d = @MDAY
$y = @YEAR

$date = $m&"-"&$m&"-"&$y
Edited by MirnesC2

Share this post


Link to post
Share on other sites
PsaltyDS

@MirnesC2: Read the topic before replying. The topic is use of a date picker control (as in the example script for GuiCtrlCreateDate). The OP is not interested in the current time/date.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×