473,657 Members | 2,316 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(DateInt erval.Day, 1, ld_rpt_date)
ld_holiday = Format(ld_due_d t, "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(DateInt erval.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 1559
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******** **********@TK2M SFTNGP09.phx.gb l...
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(DateInt erval.Day, 1, ld_rpt_date)
ld_holiday = Format(ld_due_d t, "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(DateInt erval.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******** **********@TK2M SFTNGP09.phx.gb l...
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(DateInt erval.Day, 1, ld_rpt_date)
ld_holiday = Format(ld_due_d t, "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(DateInt erval.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_d t.ToShortDateSt ring, "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_d t, "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******** **********@TK2M SFTNGP09.phx.gb l... 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(DateInt erval.Day, 1, ld_rpt_date)
ld_holiday = Format(ld_due_d t, "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(DateInt erval.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
5775
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 stores other fields from our dynamic forms. The field is called 'FormItemAnswer' and stores text, integer, date, float, etc. Anything the user can type into one of our web forms. The query looks like, select distinct from...
2
2132
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 A97 db now only stores dates in American date format, so that a British date entered as 23/04/03, for example, is stored as 03/04/23. Existing dates in the database are now displayed in American format too. I have cured the problem by...
3
11578
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 overlap existing records from the same table. I had this all working some time ago, but recently when I have gone back to do more testing, part of these validations no longer work. While there have been changes to the code in the meantime, I cannot...
4
2065
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 started doing a RTRIM(date) when I was retrieving the data. That screwed the pooch big time. Suddenly I lost
7
31822
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 current date. If not, I'd like to display the error message to ValidationSummary. It seems to make sense to me to use CompareValidator but the problem is put the current date into CompareValidator. So, I created a hidden text field in my aspx. ...
9
319
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 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...
4
1507
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
1665
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 TransactionDate =#12/09/2006# I have a record that fulfills the criterion but this query returns
11
6176
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 here will know that I have a fairly large Access 2003 database (actually split over multiple backend databases and a front-end), which users search by entering criteria on a form. Among these criteria are three date/time fields. For each, I have a...
0
8411
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7351
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.