473,796 Members | 2,464 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('$s eldate','USA') to DATE_FORMAT('US A','$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 4554
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
10714
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+ "') iam passing date format as dd/mm/yyyy my system date is in format dd/mm/yyyy is there any problem with sql server inaccepting the above format, or is there any way(universal) to send the datetime format to sql server
4
2788
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, everything works fine when testing in my computer. However, when i uploaded the web site to my hosting space in the date/time appears as
7
2464
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) sqlcomm1.ExecuteNonQuery() Query is working fine if there is value in the txtOutDate, but if user leaves the field txtOutdate empty, system insert date 1900-01-01. I want
5
4929
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 single string. The resulting variable - datetime - is exported automatically to Access. When it get's there it looks like "06/26/2006 11:30 AM". Problem is, it is a string. If I set up the database before it is populated with records and set the...
1
6144
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 it is not printing there and even not inserting in database. Tell me which data type i should use in column and insert query for inserting the string which is containing date in the database. Please do needful.
4
3263
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 want to use the format of, for an example, "5/23/2007 12:35:58 PM", to include hour/minute/second. Anyone can advise me on how to change the format?
1
2148
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 unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll Dim today As Date today = Date.Today
14
15332
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 ValidationExpression="//", but user can write date "31/02/2000" and validator says that it is correct (everybody know that Febuary has 28 or 29 days).
4
32961
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 the MYSQL Tables DateTime Type as Text. Time-formet 1. 04:02:27 16/01/2009 Time-formet 2. 16/01/2009 13:53:19 Time-formet 3. 00901E+13 Time-formet 4. Wed Jan 14 00:09:09 BDT 2009
2
2040
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 thankful you all. Ankit
0
9680
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
9528
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,...
1
10173
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
9052
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...
1
7547
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
6788
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
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
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2925
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.