473,804 Members | 3,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem in inserting date in sql server 7 through insert query

hello myself avinash
i am developing on application having vb 6 as front end and sql server 7
as back end.
when i use insert query to insert data in table then the date value of
that query is going as 01/01/1900
my query is as follows

StrSql = "Insert Into
SalesVoucher(Tr ansactionID,Vou cherNo,VoucherD ate,DebitTo,Cre ditTo,TotalAmt, Discount,ModAmt ,ModWt,Other,Ot hertype,TaxPerc ,TaxAmt,NetAmt, Advance,Narrati on,Haste)"
StrSql = StrSql & " Values(" & txtTransactionI D.text & "," &
txtChallanno.te xt & ",'" & Format(txtChall anDate.Value, "dd/mm/yyyy") &
"'," & AccCode & ",'" & IIf((Category = "Gold"), 36, 38) & "',"
StrSql = StrSql & vsAmountDesc.Va lueMatrix(RowAm ountArr(0),
2)
& "," & vsAmountDesc.Va lueMatrix(RowAm ountArr(2), 2) & "," &
val(txtModTotal .caption) & "," & val(TxtModWt.ca ption) & ","
StrSql = StrSql & vsAmountDesc.Va lueMatrix(RowAm ountArr(1),
2)
& ",'" & vsAmountDesc.Te xtMatrix(RowAmo untArr(1), 1) & "','" &
vsAmountDesc.Te xtMatrix(RowAmo untArr(4), 1) & "'," &
vsAmountDesc.Va lueMatrix(RowAm ountArr(4), 2) & ","
StrSql = StrSql & vsAmountDesc.Va lueMatrix(RowAm ountArr(3),
2)
+ val(txtModTotal .caption) & "," & val(txtAdvance. text) & ",'-'," &
IIf(Trim(txtHas te.text) <> "", RetriveAccountC ode(Trim(txtHas te.text)),
0)
& ")"

and its output is

Insert Into
SalesVoucher(Tr ansactionID,Vou cherNo,VoucherD ate,DebitTo,Cre ditTo,TotalAmt, Discount,ModAmt ,ModWt,Other,Ot hertype,TaxPerc ,TaxAmt,NetAmt, Advance,Narrati on,Haste)
Values(18,1831, '07/04/2004',150,'36', 11000,0,0,0,-10,'','1.00',10 9.9,11100,0,'-',0)

in above query though i used cdate to voucherdate value still it save in
database as 01/01/1900 though here it shows right date
plz help me its a very big issue for me & i really just fed of this
problem
Jul 20 '05 #1
2 1914
You might try running a Profiler trace to capture the actual statement
executed by SQL Server and check for any triggers that might change the
value. Note that SQL Server will interpret an empty string as 1900-01-01.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"avinash" <pa***********@ rediffmail.com> wrote in message
news:9c******** *************** *******@localho st.talkaboutdat abases.com...
hello myself avinash
i am developing on application having vb 6 as front end and sql server 7
as back end.
when i use insert query to insert data in table then the date value of
that query is going as 01/01/1900
my query is as follows

StrSql = "Insert Into
SalesVoucher(Tr ansactionID,Vou cherNo,VoucherD ate,DebitTo,Cre ditTo,TotalAmt, Discount,ModAmt ,ModWt,Other,Ot hertype,TaxPerc ,TaxAmt,NetAmt, Advance,Narrati on,Haste)"
StrSql = StrSql & " Values(" & txtTransactionI D.text & "," &
txtChallanno.te xt & ",'" & Format(txtChall anDate.Value, "dd/mm/yyyy") &
"'," & AccCode & ",'" & IIf((Category = "Gold"), 36, 38) & "',"
StrSql = StrSql & vsAmountDesc.Va lueMatrix(RowAm ountArr(0),
2)
& "," & vsAmountDesc.Va lueMatrix(RowAm ountArr(2), 2) & "," &
val(txtModTotal .caption) & "," & val(TxtModWt.ca ption) & ","
StrSql = StrSql & vsAmountDesc.Va lueMatrix(RowAm ountArr(1),
2)
& ",'" & vsAmountDesc.Te xtMatrix(RowAmo untArr(1), 1) & "','" &
vsAmountDesc.Te xtMatrix(RowAmo untArr(4), 1) & "'," &
vsAmountDesc.Va lueMatrix(RowAm ountArr(4), 2) & ","
StrSql = StrSql & vsAmountDesc.Va lueMatrix(RowAm ountArr(3),
2)
+ val(txtModTotal .caption) & "," & val(txtAdvance. text) & ",'-'," &
IIf(Trim(txtHas te.text) <> "", RetriveAccountC ode(Trim(txtHas te.text)),
0)
& ")"

and its output is

Insert Into
SalesVoucher(Tr ansactionID,Vou cherNo,VoucherD ate,DebitTo,Cre ditTo,TotalAmt, Discount,ModAmt ,ModWt,Other,Ot hertype,TaxPerc ,TaxAmt,NetAmt, Advance,Narrati on,Haste)
Values(18,1831, '07/04/2004',150,'36', 11000,0,0,0,-10,'','1.00',10 9.9,11100,0,'-',0)

in above query though i used cdate to voucherdate value still it save in
database as 01/01/1900 though here it shows right date
plz help me its a very big issue for me & i really just fed of this
problem

Jul 20 '05 #2
hi avinash
i have come across such problems frequently. i would advise u
to set the date format within dtpicker control u are using. Check
properties for the control and set the format to custom. then set the
mask.
thats it.

Regards
Debashish
Jul 20 '05 #3

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

Similar topics

4
1649
by: MAB | last post by:
I want the sum of the last payments (amount) for all customers. The last payment is with one with most recent date. And if there are more than one payment on the most recent date then the one with the higher paymentid is the last payment. for example in the given data the insert statement that starts with capital I is the last payment of that customer. The correct answer should be 2100 as given below. both queries by Erland and Anith give...
19
7294
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below. Specifically, I have a problem with this portion in the WHERE clause: DATEADD(Day,tblMyEventTableName.ReminderDays, @DateNow) Between CONVERT(smalldatetime,str(DATEPART(Month, @DateNow)+1) + '/' + str(DATEPART(Day, tblMyEventTableName.TaskDateTime)) + '/'...
5
5465
by: Ritesh | last post by:
Hi All, According to my observation using SP_WHO2 in my database, some INSERT statements are getting blocked by SELECT statements. Though the blocking SELECT statement is having ReadPast hint, i think, it will only read past locked resources but will not guarantee the select statement itself not blocking other statements(in my case Insert). According to my knowledge
4
2747
by: Bradley Burton | last post by:
I'm using Allen Brown's code for audit logging (http://allenbrowne.com/AppAudit.html), but I'm having a problem. My aud table doesn't populate with the tracking info at all. I think it might be a problem with the table set-up. I just can't find the problem. These are the fields in my table: Table1 ID (primary key) AutoNumber
1
5480
by: suslikovich | last post by:
Hi all, I am getting this error when insert values from one table to another in the first table the values are varchar (10). In the second they are datetime. The format of the data is mm/dd/yyyy to be easily converted to dates. The conversion in this case is implicit as indicated in SQL Server documentation. Here is my query: INSERT INTO Campaign (CampaignID, Name, DateStart, DateEnd, ParentID, ListID) SELECT ...
6
3312
by: fniles | last post by:
I am using VB.NET 2003 and SQL Server 2000. I have a table with a datetime column type. When inserting into the table for that column, I set it to Date.Now.ToString("T") , which is something like "2:50:54 PM". But after the row is inserted and I check the data in the database, the column data is set to "1/7/2007 2:50:04 PM" (notice today's date in front of the time). If I insert data directly into the table in the Enterprise Manager, the...
6
1896
by: Mark | last post by:
Hi, i have an application which works with date. The regional settings of the computer (XP prof. dutch version) are set to French (Belgium). Asp.net and Sql server take the short date format of the regional settings (e.g. 2/08/2007 or 13/08/2007). I checked both: that's ok. When i try to insert a date in a datetime field in sql server which is e.g.
2
3098
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography section: Discography --------------------- DiscID
58
8144
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also the parts section an i seem to be having trouble. When i try to insert into the parts section i get the error Invalid character value for cast specification. But not sure what i am doing wrong. Here is what i am using to insert. All the sections...
0
9706
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
9582
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10580
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
10335
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...
0
10082
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...
1
7621
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5525
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
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.