Calendar Control

alfcen

Well-Known Member
Licensed User
Hi Erel
The Calendar Control returns the Ticks value for any selected date plus today's current time. Is there any way of removing the time component and have Calendar.Value provide the Ticks for the selected date at 00:00 o'clock(without too many additional lines of code)?
Any plan to provide a Time Control separate from the Calendar control?
Thanks and Cheers
Robert
 

RandomCoder

Well-Known Member
Licensed User
You just need to use Date(Calender1.Value)

Regards,
RandomCoder
 

Cableguy

Expert
Licensed User
I think you just have to subtract the current time to the date selected...
somthing like

t=calendar1.value-TimeH-TimeM-TimeS
 

RandomCoder

Well-Known Member
Licensed User
Did I miss something?
Date(Calender1.Value) works for me, then if you want the current time you just need to use Time(Now)
If you need the date formated differently then you can use DateFormat to set it the way you want.

Regards,
RandomCoder
 

Cableguy

Expert
Licensed User
The Calendar Control returns the Ticks value for any selected date plus today's current time.
Since I never used the calendar control before, I simply replyed to Alfacen's question....
 

alfcen

Well-Known Member
Licensed User
RandomCoder, Cableguy,

Thank you both for your quick assistance.

Sorry, I should have been more precise. My JulianDate calculation routine accepts date and time in units of Ticks, such as JulianDate(Now).

However, when date and time, as selected with a Calendar control for date and NumericUpDown Controls for time, are other than Now then these selections need to be converted to Ticks.

I have come to the following solution:
JulianDate(DateParse(Date(cal1.Value)) + 1/24 * (numGMHour.Value + numGMMin.Value / 60 + numGMSec.Value / 3600) * cTicksPerDay)

The JulianDate routine accounts for time zone and DST.

I've spent 2 hours experimenting last night without success but just a few minutes to the solution after reading your responses this morning.
Actually, it's my first time to employ the Calendar control, too :)

Thanks a lot guys!
Robert
 

Cableguy

Expert
Licensed User
Since Alfacen question regarded the Julian calendar, i ask the same about the normal calendar...
Parsing a date string to ticks is straight foward (dateparse), wich gives us the ticks count at t 00H00s of the date...
But how to get the now ticks of the day, so that we can compare 2 dates as ticks....
because we cannot compare two dates as strings...(12/02/2008<13/02/2008 does not compute), how can it be achieved with tick?


Edit: A possible solution?

To get the ticks of the day(today):
dateparse(date(now))

can it be this simple?and so complicated, we first have to parse the actual date(ticks) to a string to parse it again to ticks?
 
Last edited:

Rioven

Active Member
Licensed User
Or how Erel's do.
TodayTicks=Now-Now Mod cTicksPerDay
 
Top