473,503 Members | 756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

insert date in desired format m-d-Y

omerbutt
638 Contributor
hi there i am inserting a desired formated date ie
m-d-y --------2-23-2008
into mysql database in which i have the field named Bill_date which has the format Date here is my query
Expand|Select|Wrap|Line Numbers
  1. $sqlAS="insert into sale_rec(Bill_no,Bill_date,Cust_name,Mop,Con_per,Con_no,Code_no,Prt_no,Stk_avl,Stk_req,U_prc,T_prc,Prd) 
  2.     values('$billno',DATE_FORMAT('$seldate','USA'),'$cname','$mop','$cper','$cno','$codeno','$prt','$stkavl','$stkreq','$uprc','$tprc','$prd')";
  3.  
i have swapped he statement DATE_FORMAT('$seldate','USA') to DATE_FORMAT('USA','$seldate') also but it still gives me the same error the date i am posting the date from a form and it is properly posted into this page and is showing the value in the variable $seldate
but i am recieving the following error
Expand|Select|Wrap|Line Numbers
  1. Column 'Bill_date' cannot be null
  2. insert into sale_rec(Bill_no,Bill_date,Cust_name,Mop,Con_per,Con_no,Code_no,Prt_no,Stk_avl,Stk_req,U_prc,T_prc,Prd) values('1007',DATE_FORMAT('02-23-2008','USA'),'sameeer','CHEQUE','oemr','0321','1000','CSV-4456','13','1','500','500','WATER_FILTER')
  3.  
Feb 23 '08 #1
4 4523
ronverdonk
4,258 Recognized Expert Specialist
DATE_FORMAT() does not have the 'USA' attribute. That option is used in function GET_FORMAT().

You'll have to use
Expand|Select|Wrap|Line Numbers
  1. INSERT ........ STR_TO_DATE('$seldate',  '%d-%m-%Y');
Ronald
Feb 23 '08 #2
mwasif
802 Recognized Expert Contributor
You can not insert date in m-d-y format. DATE only accepts yyyy-mm-dd. But you can use DATE_FORMAT() and other date functions to get the desired output.
Feb 23 '08 #3
omerbutt
638 Contributor
You can not insert date in m-d-y format. DATE only accepts yyyy-mm-dd. But you can use DATE_FORMAT() and other date functions to get the desired output.
thnaks alot buddies i knew that it wont be possble but as searching to do so cbecause i am a new beee to mysql and php used to work in access and asp before.
Feb 25 '08 #4
ronverdonk
4,258 Recognized Expert Specialist
You are welcome. See you next time around.

Ronald
Feb 25 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
10694
by: seash | last post by:
H when i execute this query, my query is crashing throwing an exception "cant convert char datatype to datetime type format my query is "insert into mytable(mydate) values ('"+ varmydate+ "')...
4
2756
by: Miguel Dias Moura | last post by:
Hello, i am just finishing a web site in ASP.net / VB using Dreamweaver MX 2004 and in all the pages i use the date/time format as follows: Date: DD-MM-YYYY Time: HH-MM (24 hours) Anyway,...
7
2420
by: Arek | last post by:
Hey, I am inserting values in the table: Dim sqlcomm1 As SqlCommand = New SqlCommand("INSERT INTO tblTasks (idTask, outdate) VALUES ('" & IDTask.text & "','" & txtOutdate.Text & "')", conn)...
5
4908
by: Takeadoe | last post by:
Gang - I'm generating date and time variables from scanned forms. Currently, the date and time values are as follows: 06/26/2006 and 11:30 AM. I've written VBA code to combine them into a...
1
6118
by: shubhra | last post by:
I am taking the date in format DD-MM-YYYY from a popup calendar in the text box in a Jsp. And i need to insert that date in to the database. But my problem is when i am printing the date in webpage...
4
3248
by: Curious | last post by:
Hi, I have a column in a grid defined as DateTime type. Currently, it's displayed in the format of "5/23/2007", for an example. It seems that it's using the default "short date" format. I...
1
2126
by: yzlin04 | last post by:
Does anyone know how to insert date into vb.net datagrid by using INSERT INTO command? From the code below, the error message is in cmd.ExecuteNonQuery() line. Here is the error message: An...
14
15280
by: | last post by:
Hi, I program in asp.net. I have a date in TextBox in format "dd/MM/yyyy". I would like to validate if the date is realy correct. I used RegularExpressionValidator with...
4
32939
by: ahmurad | last post by:
Dear Brothers, I am struggling the following four Date-Time type values which were inputted into MYSQL database in different tables. As MYSQL Default Time Format: YYYY-MM-DD HH:MM:SS, So I used...
2
2020
by: ankitjain100 | last post by:
Hello Guys, This is my first question on this platform. I want to ask that How to insert Date in MY SQL in the MM-DD-YY format i am using JSP as my frontend. Please tell me , i will be very...
0
7087
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
7334
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...
1
6993
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
5579
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,...
0
4675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3168
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...
0
1514
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 ...
1
737
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
383
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...

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.