[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Set DateTimePicker value

Posted on 2001-08-30
19
Medium Priority
?
503 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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 300 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

656 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