rcashon
asked on
Set DateTimePicker value
OK, I am using the MS DTpicker control in my web page. When you view the parameters for it you see the param tag for the Value. This value is ~ lets say 37088 that equates to 7/16/2001 . What are the calculations to arrive at this value and to be able to set it using ASP.
Thanks Randall
Thanks Randall
ASKER
I tested that and the values were 2 days off.
37000 = 4/19/2001
37086 = 7/14/2001
37185 = 10/21/2001
Close ,but not quite.
r
37000 = 4/19/2001
37086 = 7/14/2001
37185 = 10/21/2001
Close ,but not quite.
r
This value is ~ lets say 37088 that equates to 7/16/2001 .
37086 = 7/14/2001
Are you sure according to what you posted?
37086 = 7/14/2001
Are you sure according to what you posted?
ASKER
ThunderChicken,
Yes, I verified my numberson this. I am still working on the calculations. It just does not seem right. THey could not do it like a normal person would could they.
Yes, I verified my numberson this. I am still working on the calculations. It just does not seem right. THey could not do it like a normal person would could they.
It does seem strange but basically you have to set value=
DateDiff("d", "1/1/1900", Now) + 2 to get today's date.
DateDiff("d", "1/1/1900", Now) + 2 to get today's date.
ASKER
ThunderChicken,
Yes, I verified my numberson this. I am still working on the calculations. It just does not seem right. THey could not do it like a normal person would could they.
Yes, I verified my numberson this. I am still working on the calculations. It just does not seem right. THey could not do it like a normal person would could they.
ASKER
That is what I have been getting to work. I dont know why the calculat ion is like that, but it does work with the "+ 2" . OK, sort of. ? Have either of you used this in a web page? the more testing that I do the more strange things happen with this. I can get it loaded in the page and select a value which I can get passed over to a review screen, but if I press the back button the value in the calendar reverts back to the base value when the calendar page was first loaded. It does not know how to maintain state for ####. I like the format of it being a drop down and all, but if anyone knows of another that actually works smoothly I will switch in a heart beat.
Yes I have used this before.
Basically in ASP load the control like below
dim dVal
dVal = DateDiff("d", "1/1/1900", Now) + 2
response.write "<OBJECT classid=clsid:20DD1B9E-87C 4-11D1-8BE 3-0000F875 4DA1 id=DTPicker1 VIEWASTEXT><PARAM NAME='_ExtentX' VALUE='2646'><PARAM NAME='_ExtentY' VALUE='1323'><PARAM NAME='_Version' VALUE='393216'><PARAM NAME='MousePointer' VALUE='0'><PARAM NAME='Enabled' VALUE='1'><PARAM NAME='OLEDropMode' VALUE='0'><PARAM NAME='CalendarBackColor' VALUE='-2147483643'><PARAM NAME='CalendarForeColor' VALUE='-2147483630'><PARAM NAME='CalendarTitleBackCol or' VALUE='-2147483633'><PARAM NAME='CalendarTitleForeCol or' VALUE='-2147483630'><PARAM NAME='CalendarTrailingFore Color' VALUE='-2147483631'><PARAM NAME='CheckBox' VALUE='0'><PARAM NAME='CustomFormat' VALUE=''><PARAM NAME='DateIsNull' VALUE='0'><PARAM NAME='Format' VALUE='662831105'><PARAM NAME='UpDown' VALUE='0'><PARAM NAME='CurrentDate' VALUE='" & dVal & "'><PARAM NAME='MaxDate' VALUE='2958465'><PARAM NAME='MinDate' VALUE='-109205'></OBJECT>"
Basically in ASP load the control like below
dim dVal
dVal = DateDiff("d", "1/1/1900", Now) + 2
response.write "<OBJECT classid=clsid:20DD1B9E-87C
ASKER
That is what I have been getting to work. I dont know why the calculat ion is like that, but it does work with the "+ 2" . OK, sort of. ? Have either of you used this in a web page? the more testing that I do the more strange things happen with this. I can get it loaded in the page and select a value which I can get passed over to a review screen, but if I press the back button the value in the calendar reverts back to the base value when the calendar page was first loaded. It does not know how to maintain state for ####. I like the format of it being a drop down and all, but if anyone knows of another that actually works smoothly I will switch in a heart beat.
ASKER
damienm,
Your source looks just like mine. The only difference is that I have mine in the HTML page rather that doing the response.write to load it. Also, have to tested it by setting the date in the calendar and then going to another page and coming back by clicking the back button? Check your values then. Either I am having a really bad coding day or it is not maintaining state.
Your source looks just like mine. The only difference is that I have mine in the HTML page rather that doing the response.write to load it. Also, have to tested it by setting the date in the calendar and then going to another page and coming back by clicking the back button? Check your values then. Either I am having a really bad coding day or it is not maintaining state.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
damienm,
Your source looks just like mine. The only difference is that I have mine in the HTML page rather that doing the response.write to load it. Also, have to tested it by setting the date in the calendar and then going to another page and coming back by clicking the back button? Check your values then. Either I am having a really bad coding day or it is not maintaining state.
Your source looks just like mine. The only difference is that I have mine in the HTML page rather that doing the response.write to load it. Also, have to tested it by setting the date in the calendar and then going to another page and coming back by clicking the back button? Check your values then. Either I am having a really bad coding day or it is not maintaining state.
I think the reasoning behing the days are 2 off are probably because of uncalculated days that might have been added from today and 101 years ago. Maybe they added an extra day here and there to make up for something astronomical?
I think it's clear those are the days and just adding a 2 to them will solve your problem
I think it's clear those are the days and just adding a 2 to them will solve your problem
ASKER
damienm ,
Let me tell you how I resolved this. OK the datediff solved the calc problems. Now for the reload issue... WHat I had to do was store my new calendar variable as a session value when I went to the next page. When the user returns from the review page I test both the old and the new session variables. if different I load the new value . I wrapped the calendar objects like this...
<html>
<body>
<% if session("newCalVal") <> "" then %>
<OBJECT ... all calendar parms ...>
<PARAM NAME="CurrentDate" VALUE="<%=datediff("d","12 /30/1899", session("E stCompDate New"))%>">
......
</OBJECT>
<% else %>
<OBJECT ... all calendar parms ...>
<PARAM NAME="CurrentDate" VALUE="<%=datediff("d","12 /30/1899", session("E stCompDate OLD"))%>">
......
</OBJECT>
<% end if%>
You cant just switch out on the parms. It has to be the whole object. Anyway this worked out . I just hate cludgy code...
Let me tell you how I resolved this. OK the datediff solved the calc problems. Now for the reload issue... WHat I had to do was store my new calendar variable as a session value when I went to the next page. When the user returns from the review page I test both the old and the new session variables. if different I load the new value . I wrapped the calendar objects like this...
<html>
<body>
<% if session("newCalVal") <> "" then %>
<OBJECT ... all calendar parms ...>
<PARAM NAME="CurrentDate" VALUE="<%=datediff("d","12
......
</OBJECT>
<% else %>
<OBJECT ... all calendar parms ...>
<PARAM NAME="CurrentDate" VALUE="<%=datediff("d","12
......
</OBJECT>
<% end if%>
You cant just switch out on the parms. It has to be the whole object. Anyway this worked out . I just hate cludgy code...
ASKER
damienm ,
Let me tell you how I resolved this. OK the datediff solved the calc problems. Now for the reload issue... WHat I had to do was store my new calendar variable as a session value when I went to the next page. When the user returns from the review page I test both the old and the new session variables. if different I load the new value . I wrapped the calendar objects like this...
<html>
<body>
<% if session("newCalVal") <> "" then %>
<OBJECT ... all calendar parms ...>
<PARAM NAME="CurrentDate" VALUE="<%=datediff("d","12 /30/1899", session("E stCompDate New"))%>">
......
</OBJECT>
<% else %>
<OBJECT ... all calendar parms ...>
<PARAM NAME="CurrentDate" VALUE="<%=datediff("d","12 /30/1899", session("E stCompDate OLD"))%>">
......
</OBJECT>
<% end if%>
You cant just switch out on the parms. It has to be the whole object. Anyway this worked out . I just hate cludgy code...
Let me tell you how I resolved this. OK the datediff solved the calc problems. Now for the reload issue... WHat I had to do was store my new calendar variable as a session value when I went to the next page. When the user returns from the review page I test both the old and the new session variables. if different I load the new value . I wrapped the calendar objects like this...
<html>
<body>
<% if session("newCalVal") <> "" then %>
<OBJECT ... all calendar parms ...>
<PARAM NAME="CurrentDate" VALUE="<%=datediff("d","12
......
</OBJECT>
<% else %>
<OBJECT ... all calendar parms ...>
<PARAM NAME="CurrentDate" VALUE="<%=datediff("d","12
......
</OBJECT>
<% end if%>
You cant just switch out on the parms. It has to be the whole object. Anyway this worked out . I just hate cludgy code...
ASKER
Thunderchicken, yes I agree with you however it would have nice of the developer to use standard conventions for the calendar. Not counting the fact that the control is marked unsafe for scripting ... Someone had been out tooo later the night before when they released that one...
ASKER
Thanks for the input.
hi...i'm planning to use datetime picker on my asp code but it seems like its not working...
can anyone here give me a brief tutorial on how to do it?
do i have to register some activex file or?
can anyone here give me a brief tutorial on how to do it?
do i have to register some activex file or?
rcashon,
well solved and explained, i had exactly the same problem and guess what you saved me lot of time to solve that problem Thanks
Cools_-
well solved and explained, i had exactly the same problem and guess what you saved me lot of time to solve that problem Thanks
Cools_-
I believe they count from 1/1/1900 + 37088 days is 7/16/2001
Try
<%
Response.Write (datediff("d","1/1/1900","
%>
it gives you 37086