Solved

Set DateTimePicker value

Posted on 2001-08-30
19
424 Views
Last Modified: 2012-05-04
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
0
Comment
Question by:rcashon
  • 11
  • 3
  • 3
  • +2
19 Comments
 
LVL 11

Expert Comment

by:thunderchicken
ID: 6442116
37088 / 365 = 101.xxxxx

I believe they count from 1/1/1900 + 37088 days is 7/16/2001

Try

<%
  Response.Write (datediff("d","1/1/1900","7/16/2001"))


%>

it gives you 37086
0
 
LVL 1

Author Comment

by:rcashon
ID: 6442210
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
0
 
LVL 11

Expert Comment

by:thunderchicken
ID: 6442269
This value is ~ lets say 37088 that equates to 7/16/2001 .

37086 = 7/14/2001

Are you sure according to what you posted?
0
 
LVL 1

Author Comment

by:rcashon
ID: 6444325
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.
0
 
LVL 2

Expert Comment

by:damienm
ID: 6444416
It does seem strange but basically you have to set value=
DateDiff("d", "1/1/1900", Now) + 2 to get today's date.
0
 
LVL 1

Author Comment

by:rcashon
ID: 6444418
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.
0
 
LVL 1

Author Comment

by:rcashon
ID: 6444431
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.
0
 
LVL 2

Expert Comment

by:damienm
ID: 6444493
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-87C4-11D1-8BE3-0000F8754DA1 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='CalendarTitleBackColor' VALUE='-2147483633'><PARAM NAME='CalendarTitleForeColor' VALUE='-2147483630'><PARAM NAME='CalendarTrailingForeColor' 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>"

0
 
LVL 1

Author Comment

by:rcashon
ID: 6444523
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.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:rcashon
ID: 6444552
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.
 
0
 
LVL 2

Accepted Solution

by:
damienm earned 100 total points
ID: 6444918
I see what you mean

I am not sure, how to do this as activex controls are harder to work with in client side.  But if you can save a cookie in client side when the date changes then you can call this cookie in server side when the page is reloaded.

Something like

<%dim dVal
if Request.Cookies ("TimerVal") <> "" then
   dVal = DateDiff("d", "1/1/1900", Request.Cookies ("TimerVal")) + 2
else
   dVal = DateDiff("d", "1/1/1900", Now) + 2
end if

response.write "<OBJECT classid=clsid:20DD1B9E-87C4-11D1-8BE3-0000F8754DA1 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='CalendarTitleBackColor' VALUE='-2147483633'><PARAM NAME='CalendarTitleForeColor' VALUE='-2147483630'><PARAM NAME='CalendarTrailingForeColor' 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>" %><META content="MSHTML 5.00.2919.6307" name=GENERATOR>



<SCRIPT LANGUAGE=vbscript>
function DTPicker1_change()
document.cookie = "TimerVal=" & DTPicker1.Value
end function
</SCRIPT>
0
 
LVL 1

Author Comment

by:rcashon
ID: 6444938
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.
 
0
 
LVL 11

Expert Comment

by:thunderchicken
ID: 6444947
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
0
 
LVL 1

Author Comment

by:rcashon
ID: 6444974
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("EstCompDateNew"))%>">
    ......
    </OBJECT>
<% else %>

    <OBJECT   ... all calendar parms ...>
          <PARAM NAME="CurrentDate" VALUE="<%=datediff("d","12/30/1899",session("EstCompDateOLD"))%>">
    ......
    </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...



   
0
 
LVL 1

Author Comment

by:rcashon
ID: 6444976
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("EstCompDateNew"))%>">
    ......
    </OBJECT>
<% else %>

    <OBJECT   ... all calendar parms ...>
          <PARAM NAME="CurrentDate" VALUE="<%=datediff("d","12/30/1899",session("EstCompDateOLD"))%>">
    ......
    </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...



   
0
 
LVL 1

Author Comment

by:rcashon
ID: 6444988
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...
0
 
LVL 1

Author Comment

by:rcashon
ID: 7326484
Thanks for the input.
0
 
LVL 1

Expert Comment

by:twj100
ID: 7632664
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?
0
 

Expert Comment

by:Cools_-
ID: 9419142
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_-
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now