Showing posts with label date. Show all posts
Showing posts with label date. Show all posts

Saturday, March 31, 2012

set a date value

Dear sir,

We are on the week of 27 in year 2004. So this week is "2004-27", last week
is "2004-26",

My question is how can I get the first sunday of week "2004-26", how can I
change string "2004-26" into a DateTime variable with the value of first
sunday of week 2004-26?

--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.comThe easiest way I could think of would be to check what the first day of the
year is (1/1/2004) through the DayOfWeek property of the DateTime class and
calculate the offset between it and the previous Sunday.

For 2004, calling DateTime.DayOfWeek for 1/1/2004 would return Thursday.
Therefore, the first week of 2004 (by week numbers) started on Sunday,
12/28/2003. To determine the Sunday starting any given week during 2004 you
could simply calculate it via:

public DateTime GetWeekStart(int WeekNumber)
{
return FirstSundayOfYear.AddDays(7*(WeekNumber-1));
}

The rationale for (WeekNumber-1) is that the FirstSundayOfYear would already
be set to 12/28/2003 so if you were looking for week 1 then you would want
to add 0 days as opposed to 7.

You indicated that you wanted to convert a string (2004-26) into a DateTime
for the first sunday of each week. What I would probably do in this
scenario since obviously no direct conversion exists would be to define a
WeekDictionary class derived from System.Collections.DictionaryBase and set
the key of the key to the desired string and the value to the appropriate
DateTime value.

Hope this helps!

"Guoqi Zheng" <no@.sorry.nl> wrote in message
news:uIdNKvDXEHA.128@.TK2MSFTNGP10.phx.gbl...
> Dear sir,
> We are on the week of 27 in year 2004. So this week is "2004-27", last
week
> is "2004-26",
> My question is how can I get the first sunday of week "2004-26", how can I
> change string "2004-26" into a DateTime variable with the value of first
> sunday of week 2004-26?
> --
> Kind regards
> Guoqi Zheng
> guoqi AT meetholland dot com
> Http://www.meetholland.com

set a date value

Dear sir,
We are on the w of 27 in year 2004. So this w is "2004-27", last w
is "2004-26",
My question is how can I get the first sunday of w "2004-26", how can I
change string "2004-26" into a DateTime variable with the value of first
sunday of w 2004-26?
Kind regards
Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.comThe easiest way I could think of would be to check what the first day of the
year is (1/1/2004) through the DayOfW property of the DateTime class and
calculate the offset between it and the previous Sunday.
For 2004, calling DateTime.DayOfW for 1/1/2004 would return Thursday.
Therefore, the first w of 2004 (by w numbers) started on Sunday,
12/28/2003. To determine the Sunday starting any given w during 2004 you
could simply calculate it via:
public DateTime GetWStart(int WNumber)
{
return FirstSundayOfYear.AddDays(7*(WNumber-1));
}
The rationale for (WNumber-1) is that the FirstSundayOfYear would already
be set to 12/28/2003 so if you were looking for w 1 then you would want
to add 0 days as opposed to 7.
You indicated that you wanted to convert a string (2004-26) into a DateTime
for the first sunday of each w. What I would probably do in this
scenario since obviously no direct conversion exists would be to define a
WDictionary class derived from System.Collections.DictionaryBase and set
the key of the key to the desired string and the value to the appropriate
DateTime value.
Hope this helps!
"Guoqi Zheng" <no@.sorry.nl> wrote in message
news:uIdNKvDXEHA.128@.TK2MSFTNGP10.phx.gbl...
> Dear sir,
> We are on the w of 27 in year 2004. So this w is "2004-27", last
w
> is "2004-26",
> My question is how can I get the first sunday of w "2004-26", how can I
> change string "2004-26" into a DateTime variable with the value of first
> sunday of w 2004-26?
> --
> Kind regards
> Guoqi Zheng
> guoqi AT meetholland dot com
> Http://www.meetholland.com
>
>

Thursday, March 29, 2012

set date on calendar in a FormView template

Hi,

My calendar is inside a FormView template as users are entering new dates.

I want the month shown to be the same as the last one they entered, but after an Insert, the control revert back to the current month.

I can fetch the moth via SQL or stoer in a cookie, but I don't know how to access the control, as it's embedded in the FormVIew.

Thanks if you can help.

NEIL

1protected void myFormView_DataBound(object sender, EventArgs e)2 {3 Calendar myCal = (Calendar)myFormView.FindControl("myCalendar");4// set the Visible Date in the calendar to the Current Month5 myCal.VisibleDate = DateTime.Now();6 }

Line 3 finds the Calendar Control within the FormView.

Line 5 sets the VisibleDate property of the calendar to the Current Month, or whatever date you want to place on the right side of the =.


Hi,

I'm writing in VB, can you translate?

Cheers,

NEIL


1Protected Sub FormView1_DataBound(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles FormView1.DataBound2Dim myCalAs Calendar =CType(FormView1.FindControl("myCalendar"), Calendar)3 myCal.VisibleDate = DateTime.Now4End Sub
 
If this is what you needed, please mark it as your answer...Thanks!!
 

Monday, March 26, 2012

Set defualt date as Week Day before Today.

VB.Net and a simple aspx.net page.

I have this simple code that puts Today's date in these 2 textboxes. Can
some one tell me how to set these two boxes with yesterday's date excluding
weekends?

Thanks!
phil

----------

Dim dtmToday As String

dtmToday = Now.Date.ToString("MM/d/yyy")

TextBox1.Text = dtmToday

TextBox2.Text = dtmTodayThanks, but that didn't work. Your code just took the date back 7 days
INCLUDING WEEKENDS. If the textbox is 12/11/06, it is now 12/4/06. If I
change the code to -1, it will go back one day but it does not disregard the
weekends. How do you disregard the weekends?

"Saubz" <saubz@.newsgroups.nospamwrote in message
news:6FC8AB4E-D0BB-4843-BE0C-3EAB4E576AC7@.microsoft.com...

Quote:

Originally Posted by

Phillip,
>
Try this out
>
>
TextBox1.Text = DateAdd(DateInterval.Day, -7, DateTime.Now)
>
>
>
"Phillip Vong" wrote:
>

Quote:

Originally Posted by

>VB.Net and a simple aspx.net page.
>>
>I have this simple code that puts Today's date in these 2 textboxes. Can
>some one tell me how to set these two boxes with yesterday's date
>excluding
>weekends?
>>
>Thanks!
>phil
>>
>----------
>>
>>
>>
>Dim dtmToday As String
>>
>dtmToday = Now.Date.ToString("MM/d/yyy")
>>
>TextBox1.Text = dtmToday
>>
>TextBox2.Text = dtmToday
>>
>>
>>


On Mon, 11 Dec 2006 18:18:00 -0500, Phillip Vong wrote:

Quote:

Originally Posted by

Thanks, but that didn't work. Your code just took the date back 7 days
INCLUDING WEEKENDS. If the textbox is 12/11/06, it is now 12/4/06. If I
change the code to -1, it will go back one day but it does not disregard the
weekends. How do you disregard the weekends?


Hey Philip,

Try this out. Its not pretty but it works

sub Main
' This should return monday the 11th
Console.WriteLine( _
GetLastBusinessDay(new DateTime(2006,12,12),1))
'This should return friday the 8th
Console.WriteLine( _
GetLastBusinessDay(new DateTime(2006,12,12),2))
Console.ReadLine()
end sub

function GetLastBusinessDay (theDate as DateTime, daysAgo as Integer) as
DateTime
'
' Some local variables
'
dim counter as integer
dim temp as DateTime =theDate
'
' Put in a loop
'
while true
'
' Do some error checking
'
if theDate=DateTime.MinValue
return DateTime.MinValue
end if

'
' Decrement the day
'
temp= temp.AddDays(-1)
'
' Check if it is a weekday
'
select case temp.DayOfWeek
case DayOfWeek.Monday to DayOfWeek.Friday
'
' It is! Increment the counter
'
counter=counter+1
end select
'
' Now check if the counter is equal to
' the days we want
'
if counter=daysago then
return temp
end if

end while
end function
--
Bits.Bytes
http://bytes.thinkersroom.com

set Expires tag for images?

Hi - I want to reduce the download time of various pages by setting the
'Expires' tag for various images to a future date (this will then stop the
browser from re-requesting these for each new session).

I'm hosting on a commercial service so I don't have direct access to IIS
configuration. Is there anyway I can control this from my server-side code?

Thanks,

Paul.Paul W wrote:

> Hi - I want to reduce the download time of various pages by setting
> the 'Expires' tag for various images to a future date (this will then
> stop the browser from re-requesting these for each new session).
> I'm hosting on a commercial service so I don't have direct access to
> IIS configuration. Is there anyway I can control this from my
> server-side code?

Not if the images are served directly by IIS. Your ISP should be able
to change the server configuration to allow for caching.

BTW, you should prefer Cache-Control: max-age over Expires.

Cheers,
--
http://www.joergjooss.de
mailto:news-reply@.joergjooss.de
Currently the images ARE directly served by IIS. Can you point me to how
else I could do this so I can set the "Cache-Control: max-age"? Thanks,

Paul.
----
"Joerg Jooss" <news-reply@.joergjooss.de> wrote in message
news:xn0e3b26b6h8ll002@.msnews.microsoft.com...
> Paul W wrote:
>> Hi - I want to reduce the download time of various pages by setting
>> the 'Expires' tag for various images to a future date (this will then
>> stop the browser from re-requesting these for each new session).
>>
>> I'm hosting on a commercial service so I don't have direct access to
>> IIS configuration. Is there anyway I can control this from my
>> server-side code?
> Not if the images are served directly by IIS. Your ISP should be able
> to change the server configuration to allow for caching.
> BTW, you should prefer Cache-Control: max-age over Expires.
> Cheers,
> --
> http://www.joergjooss.de
> mailto:news-reply@.joergjooss.de
Paul W wrote:

> Currently the images ARE directly served by IIS. Can you point me to
> how else I could do this so I can set the "Cache-Control: max-age"?
> Thanks,

You could implemment a HttpHandler that serves your images, but this is
really a waste of time. Ask your service provider to change your IIS
configuration.

Cheers,
--
http://www.joergjooss.de
mailto:news-reply@.joergjooss.de

Thursday, March 22, 2012

Set Minimum Date Calendar Control

Does anyone know how to set a minimum selectable date in the calendar
server control that come with VS2005?

I do not want to use validators...I want the days before the selectable
period to be grayed out.Wow. I guess most people do not use this control. I am now wishing I
had some funds to purchase a date control that is actually useful!

I'll try another Q: How do I make a date to show as selected/shaded
(preselect) when the calendar is rendered on my web page? I tried
setting both the "TodaysDate" and "SelectedDate" properties with code.
I then set a breakpoint and verified that this is happening...but the
user still has to click on the day in the calendar to get it to show as
selected/shaded. Does anyone have any ideas?

Joey wrote:
> Does anyone know how to set a minimum selectable date in the calendar
> server control that come with VS2005?
> I do not want to use validators...I want the days before the selectable
> period to be grayed out.
Got the second Q answered. I was setting those properties to DateTime
variables which had values like "1/1/2006 4:24:23 PM". Once I changed
them to "1/1/2006 12:00:00 AM" it worked...strange.

Still working on the first Q.
Does that mean that you don't need to have
"funds to purchase a date control that is actually useful" ?

;-)

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Joey" <joey.powell@.topscene.com> wrote in message
news:1142452273.636929.143820@.e56g2000cwe.googlegr oups.com...
> Got the second Q answered. I was setting those properties to DateTime
> variables which had values like "1/1/2006 4:24:23 PM". Once I changed
> them to "1/1/2006 12:00:00 AM" it worked...strange.
> Still working on the first Q.