By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,640 Members | 2,355 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,640 IT Pros & Developers. It's quick & easy.

Weird date format problem

P: n/a
Hi all :-)

I have a bit of code that chacks for the last day of the Month, and if it falls on a week-end, sets the due date to the Monday after...

I'm trying to get the date to go to the Tuesday afterward, if the last day of the month falls on the week-end and the Monday afterwards is a holiday... to test I set the date to 11/30/2006, to make the due date fall on 12/31/2006 which is a Sunday and makes 1/1/2007 a holiday.

I've put in the following code:

If ls_day = "Sunday" Then
ld_due_dt = DateAdd(DateInterval.Day, 1, ld_rpt_date)
ld_holiday = Format(ld_due_dt, "MM/dd")
If ld_holiday = "01/01" Or ld_holiday = "05/31" _
Or ld_holiday = "09/01" Or ld_holiday = "11/30" Then
If ls_day = "Monday" Then
ld_due_dt = DateAdd(DateInterval.Day, 1, ld_rpt_date)
lbl_due.Text = ld_due_dt
End If
End If
Else
lbl_due.Text() = ls_duedate
End If

For some reason, the ld_holiday date keeps coming back with the value of #1/1/2004# Weird. How can I get it to come back with 1/1/2007, so I can test? TIA

Coleen

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
sorry, that was 4 y's on my last post...

yyyy gives you 2007

yy gives you 07

or whateer.

<Coleen> wrote in message news:%2******************@TK2MSFTNGP09.phx.gbl...
Hi all :-)

I have a bit of code that chacks for the last day of the Month, and if it falls on a week-end, sets the due date to the Monday after...
I'm trying to get the date to go to the Tuesday afterward, if the last day of the month falls on the week-end and the Monday afterwards is a holiday...
to test I set the date to 11/30/2006, to make the due date fall on
12/31/2006 which is a Sunday and makes 1/1/2007 a holiday.
I've put in the following code:

If ls_day = "Sunday" Then
ld_due_dt = DateAdd(DateInterval.Day, 1, ld_rpt_date)
ld_holiday = Format(ld_due_dt, "MM/dd")
If ld_holiday = "01/01" Or ld_holiday = "05/31" _
Or ld_holiday = "09/01" Or ld_holiday = "11/30" Then
If ls_day = "Monday" Then
ld_due_dt = DateAdd(DateInterval.Day, 1, ld_rpt_date)
lbl_due.Text = ld_due_dt
End If
End If
Else
lbl_due.Text() = ls_duedate
End If

For some reason, the ld_holiday date keeps coming back with the value of #1/1/2004# Weird. How can I get it to come back with 1/1/2007, so I can
test? TIA
Coleen

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup

engine supports Post Alerts, Ratings, and Searching.
Nov 20 '05 #2

P: n/a
Use the string.format instead...
String.Format("{0:MM/dd/yy}", mydatevalue)

<I *think* this works, you may have to modify the '/'>

<Coleen> wrote in message news:%2******************@TK2MSFTNGP09.phx.gbl...
Hi all :-)

I have a bit of code that chacks for the last day of the Month, and if it falls on a week-end, sets the due date to the Monday after...
I'm trying to get the date to go to the Tuesday afterward, if the last day of the month falls on the week-end and the Monday afterwards is a holiday...
to test I set the date to 11/30/2006, to make the due date fall on
12/31/2006 which is a Sunday and makes 1/1/2007 a holiday.
I've put in the following code:

If ls_day = "Sunday" Then
ld_due_dt = DateAdd(DateInterval.Day, 1, ld_rpt_date)
ld_holiday = Format(ld_due_dt, "MM/dd")
If ld_holiday = "01/01" Or ld_holiday = "05/31" _
Or ld_holiday = "09/01" Or ld_holiday = "11/30" Then
If ls_day = "Monday" Then
ld_due_dt = DateAdd(DateInterval.Day, 1, ld_rpt_date)
lbl_due.Text = ld_due_dt
End If
End If
Else
lbl_due.Text() = ls_duedate
End If

For some reason, the ld_holiday date keeps coming back with the value of #1/1/2004# Weird. How can I get it to come back with 1/1/2007, so I can
test? TIA
Coleen

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup

engine supports Post Alerts, Ratings, and Searching.
Nov 20 '05 #3

P: n/a
The problem is that I want to format the date so that it doesn't matter what year it is... so the date comes up formatted as "MM/dd" with out ANY year because it needs to be specific to the month and day only. I just keep getting the date returned as MM/dd/yyyy. I'll try it with the String format you've suggested, and see if that will allow me to pass the date without the year...

Thanks :-)

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Nov 20 '05 #4

P: n/a
I tried using:

ld_holiday = Format(ld_due_dt.ToShortDateString, "MM/dd")

This doesn't work because I am using a date format, not a string format. Any suggestion on how to convert this to a string correctly to allow me to format it?

TIA

Coleen

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Nov 20 '05 #5

P: n/a
Coleen,
In addition to CJ's comments.

Which version of the framework are you using? VS.NET 2002 & .NET 1.0 or
VS.NET 2003 & .NET 1.1?

How is ld_holiday defined? It appears to be a string.

Dim ld_holiday As String
ld_holiday = Format(ld_due_dt, "MM/dd")
Gives "01/01" in VS.NET 2003. If you defined ld_holiday as a Date, then
"There's the rub"!

You are not using Option Strict On, so VB.NET will convert the string
"01/01" to a date for you, seeing as "01/01" does not include a Year, one
will be supplied for you.

I would recommend you use Option Strict On, and declare the ld_holiday as
the correct type for how you are using it. Based on your code snippet its a
string!

Hope this helps
Jay

<Coleen> wrote in message news:%2******************@TK2MSFTNGP09.phx.gbl... Hi all :-)

I have a bit of code that chacks for the last day of the Month, and if it falls on a week-end, sets the due date to the Monday after...
I'm trying to get the date to go to the Tuesday afterward, if the last day of the month falls on the week-end and the Monday afterwards is a holiday...
to test I set the date to 11/30/2006, to make the due date fall on
12/31/2006 which is a Sunday and makes 1/1/2007 a holiday.
I've put in the following code:

If ls_day = "Sunday" Then
ld_due_dt = DateAdd(DateInterval.Day, 1, ld_rpt_date)
ld_holiday = Format(ld_due_dt, "MM/dd")
If ld_holiday = "01/01" Or ld_holiday = "05/31" _
Or ld_holiday = "09/01" Or ld_holiday = "11/30" Then
If ls_day = "Monday" Then
ld_due_dt = DateAdd(DateInterval.Day, 1, ld_rpt_date)
lbl_due.Text = ld_due_dt
End If
End If
Else
lbl_due.Text() = ls_duedate
End If

For some reason, the ld_holiday date keeps coming back with the value of #1/1/2004# Weird. How can I get it to come back with 1/1/2007, so I can
test? TIA
Coleen

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup

engine supports Post Alerts, Ratings, and Searching.
Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.