Current location: Hot Scripts Forums » Programming Languages » ASP » Save date in to a table


Save date in to a table

Reply
  #1 (permalink)  
Old 09-25-05, 12:43 AM
suhabassam suhabassam is offline
Newbie Coder
 
Join Date: Sep 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Save date in to a table

Hi,
I am trying to save some fields in a table, one field with type Date. It only accepts date with the following format (01-Jan-05). I am reading the date as a string (24/09/2005) and then convert it to date.
But i do not know to convert it to the following format (24-Sep-05) to store it in the table?? Please I need help urgently. This is my code :
<%
String issuedate = request.getParameter("issuedate");
DateFormat format = new SimpleDateFormat("dd/MM/yyyy");
myIssueDate = format.parse(issuedate);
mindecree.setIssueDate(new java.sql.Date(myIssueDate.getTime()));
%>

Note:I've tried using the following:
SimpleDateFormat format = new SimpleDateFormat("dd-MMM-yy"); Date myIssueDate = format.parse(issuedate);
But i got (Unparseable date:"19/5/2005" ) error .
Any Idea pls.???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 09-25-05, 09:54 AM
koncept
Guest
 
Posts: n/a
just use the date format do not specify options other than small, medium, or long (if i remember right) then you can use now() to set the date time based upon the server.

when you want to display it you can use formatdatetime(strin,format)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 10-26-05, 07:23 AM
toth toth is offline
Newbie Coder
 
Join Date: Oct 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
You can also try this where you need to display the date

Code:
[<%= DoDateTime((YourRecordsetHere.Fields.Item("issuedate").Value), 1, 2057)%>]
you can change 2057 to your local settings, if it isn't correct

Put this code on top of your page

Code:
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>					
function DoDateTime(str, nNamedFormat, nLCID)				
	dim strRet								
	dim nOldLCID								
										
	strRet = str								
	If (nLCID > -1) Then							
		oldLCID = Session.LCID						
	End If									
										
	On Error Resume Next							
										
	If (nLCID > -1) Then							
		Session.LCID = nLCID						
	End If									
										
	If ((nLCID < 0) Or (Session.LCID = nLCID)) Then				
		strRet = FormatDateTime(str, nNamedFormat)			
	End If									
										
	If (nLCID > -1) Then							
		Session.LCID = oldLCID						
	End If									
										
	DoDateTime = strRet							
End Function									
</SCRIPT>
It will display 29/10/2005 as 29 October 2005
So store it as dd/mm/yyyy

If the table got the value Now() it will auto generate the date
Leave it blank if you want to add a custom date.
Attached Images
File Type: jpg ASP_DateNowSample.jpg (8.2 KB, 198 views)

Last edited by toth; 10-26-05 at 07:50 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Querying a table based on phpBB2's usergroup table Venthos PHP 1 09-01-05 02:42 PM
How to save a Date in MySQL jozin PHP 4 11-01-04 08:59 PM
Problem with a sort table js function tdubyou JavaScript 0 05-03-04 10:19 AM
auto table resize derick_2k JavaScript 4 04-26-04 03:32 PM
Newbie MySQL fccolon PHP 2 03-16-04 11:54 AM


All times are GMT -5. The time now is 08:25 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.