473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Weird date format problem

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
5 1543
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Russell | last post by:
I'm having a fit with a query for a range of dates. The dates are being returned from a view. The table/field that they are being selected from stores them as varchar and that same field also...
2
by: andybriggs | last post by:
An Access 97 database is running quite happily on about 30 IBM ThinkPads. Some of the users, however, have now installed some components of Office 2000 like Word and Excel. On those machines, the...
3
by: Lyn | last post by:
Hi, I am developing a project in which I am checking for records with overlapping start/end dates. Record dates must not overlap date of birth, date of death, be in the future, and must not...
4
by: Paul | last post by:
Hi, Everything went fine getting a short date format out of SQL into my DataGrid with this: <%# DataBinder.Eval(Container.DataItem, "Created", "{0:d}")%> Then I got too fancy in SQL and...
7
by: James P. | last post by:
Hello there, In my asp.net page using VB, I have a date text field in mm/dd/yyyy format. When a date is entered, I'd like to validate it to make sure the date is greater than or equal to the...
9
by: Coleen | last post by:
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...
4
by: davemateer | last post by:
Hi SQL Server 2000 Database: Table: Thing Columns: id (int), nameOfThing (int), dateOfThing (datetime) I put some data in it: 1, dave, 9/11/1973 14:33:22
5
by: Anja | last post by:
Hi everyone, I want to write a simple SQL statement that does a comparison on a date field. For a simple test, I have the following SQL Statement: SELECT * FROM Records_T where...
11
by: Killer42 | last post by:
Hi all. Short version: DtPicker goes strange when .Enabled changed in VBA code, looking for solution or good workaround. Looooong version: Those of you who have been following various threads...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.