473,396 Members | 1,858 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,396 software developers and data experts.

DATE HELLLPPPP

Hi
I have a vb.net app asp.net 1.1 that uses "NOW" to get the date and the
uses a sql statement to write it to an MS SQL server remotely hosted!

Well the date has flipped to 13/01/2006 the data base wants it in US format
what's the best way of changing it?!

I tried format(now, "MM/DD/YYYY HH:MM:SS") but this just gives me an error
Cast from string "01/DD/YYYY 15:01" to type 'Date' is not valid.
HELLPP
Jan 13 '06 #1
5 1436
Adrian,

Be aware that the IDE from VBNet shows dates between ## in USA format.
(Don't be confused if you use C# as well, that IDE shows the datetime in
your local setting).

The actual DateTimes are in ticks (Starting in 1753 for SQL server and at
1-1-1 for Net).

Therefore try to avoid any fixed changes from a datetime, normally Net does
that for you.

Cor
Jan 13 '06 #2
"Adrian" <Ad****@nospamhotmail.com.uk> schrieb
Hi
I have a vb.net app asp.net 1.1 that uses "NOW" to get the date
and the uses a sql statement to write it to an MS SQL server
remotely hosted!

Well the date has flipped to 13/01/2006 the data base wants it in US
format what's the best way of changing it?!

I tried format(now, "MM/DD/YYYY HH:MM:SS") but this just gives me
an error Cast from string "01/DD/YYYY 15:01" to type 'Date' is not
valid.


Use parameters:

sqlcommand.parameters.add("@param", sqldatatype.datetime").value = now
Armin

Jan 13 '06 #3
Hi,
Thanks, I got around it for now by using substring to re construct the
date! as this SQL is new to me:(

So if I use parameters how do I do it?

is each part of the query constructed using it?

how would i use it to say do this:
Cmd = New SqlCommand(strSql, Conn)
strSql = "INSERT INTO DownloadLog(Stamp, XXX, IPAddress, YYY) VALUES('" &
dateTStamp & "', '" & strXXX & " ','" & strIP & "' ,'" & strYYY & "')"
Conn.Open()
Cmd.ExecuteNonQuery()

thanks
"Armin Zingler" <az*******@freenet.de> wrote in message
news:un*************@tk2msftngp13.phx.gbl...
"Adrian" <Ad****@nospamhotmail.com.uk> schrieb
Hi
I have a vb.net app asp.net 1.1 that uses "NOW" to get the date
and the uses a sql statement to write it to an MS SQL server
remotely hosted!

Well the date has flipped to 13/01/2006 the data base wants it in US
format what's the best way of changing it?!

I tried format(now, "MM/DD/YYYY HH:MM:SS") but this just gives me
an error Cast from string "01/DD/YYYY 15:01" to type 'Date' is not
valid.


Use parameters:

sqlcommand.parameters.add("@param", sqldatatype.datetime").value = now
Armin

Jan 13 '06 #4
"Adrian" <Ad****@nospamhotmail.com.uk> schrieb
Hi,
Thanks, I got around it for now by using substring to re construct
the date! as this SQL is new to me:(

So if I use parameters how do I do it?

is each part of the query constructed using it?

how would i use it to say do this:
Cmd = New SqlCommand(strSql, Conn)
strSql = "INSERT INTO DownloadLog(Stamp, XXX, IPAddress, YYY)
VALUES('" & dateTStamp & "', '" & strXXX & " ','" & strIP & "' ,'" &
strYYY & "')" Conn.Open()
Cmd.ExecuteNonQuery()

You'll find many samples if you press <F1>. ;-)
strSql = "INSERT INTO DownloadLog(Stamp, XXX, IPAddress, YYY) VALUES(@Stamp,
@xxx, @ipadress, @yyy)
Cmd = New SqlCommand(strSql, Conn)
with cmd.parameters
.add("@stamp", sqldbtype.datetime).value = stamp
.add("@xxx", sqldbtype.varchar).value = xxx
.add("@ipaddress", sqldbtype.varchar).value = ipaddress
.add("@yyy", sqldbtype.varchar).value = yyy
end with

Conn.Open()
Cmd.ExecuteNonQuery()
Variable stamp should be declare as DateTime, the others as string. I
assumed that xxx, ipaddress and yyy are varchar in the database.
If you will have further ADO.Net (language unrelated) questions,
microsoft.public.dotnet.framework.adonet is the best place to ask.
Armin

Jan 13 '06 #5
Great thanks for your help

"Armin Zingler" <az*******@freenet.de> wrote in message
news:eN**************@TK2MSFTNGP15.phx.gbl...
"Adrian" <Ad****@nospamhotmail.com.uk> schrieb
Hi,
Thanks, I got around it for now by using substring to re construct
the date! as this SQL is new to me:(

So if I use parameters how do I do it?

is each part of the query constructed using it?

how would i use it to say do this:
Cmd = New SqlCommand(strSql, Conn)
strSql = "INSERT INTO DownloadLog(Stamp, XXX, IPAddress, YYY)
VALUES('" & dateTStamp & "', '" & strXXX & " ','" & strIP & "' ,'" &
strYYY & "')" Conn.Open()
Cmd.ExecuteNonQuery()

You'll find many samples if you press <F1>. ;-)
strSql = "INSERT INTO DownloadLog(Stamp, XXX, IPAddress, YYY)
VALUES(@Stamp, @xxx, @ipadress, @yyy)
Cmd = New SqlCommand(strSql, Conn)
with cmd.parameters
.add("@stamp", sqldbtype.datetime).value = stamp
.add("@xxx", sqldbtype.varchar).value = xxx
.add("@ipaddress", sqldbtype.varchar).value = ipaddress
.add("@yyy", sqldbtype.varchar).value = yyy
end with

Conn.Open()
Cmd.ExecuteNonQuery()
Variable stamp should be declare as DateTime, the others as string. I
assumed that xxx, ipaddress and yyy are varchar in the database.
If you will have further ADO.Net (language unrelated) questions,
microsoft.public.dotnet.framework.adonet is the best place to ask.
Armin

Jan 13 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
2
by: Tjerk | last post by:
Hello all, I have the script below to change an image depending on the date upto january it worked fine but then it just stopped working does anybody have an idea how I can make it work again or...
9
by: Thomas R. Hummel | last post by:
Hello, I am importing data that lists rates for particular coverages for a particular period of time. Unfortunately, the data source isn't very clean. I've come up with some rules that I think...
30
by: Dr John Stockton | last post by:
It has appeared that ancient sources give a method for Numeric Date Validation that involves numerous tests to determine month length; versions are often posted by incomers here. That sort of code...
3
by: captain | last post by:
Below is the sql for data with same date need to extract + or - 5 days data of same date also. How to also get data of + and - days related to same date. SELECT IM.Area, IM.Location,...
1
by: Liz Malcolm | last post by:
Hello and TIA. I have a DE form with an option group that if daily is selected todays date is used for start and end date, if weekly is selected Monday - Friday is used. I am trying to add a...
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...
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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...
0
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...
0
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,...

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.