How do we format a date as "dd/mm/yy"
Hi everybody.
I wish to format a date as "dd/mm/yy"
For example, today should be 12/08/14 (2 digits for the year)
I got this formula from the forum:
DECLARE @today varchar(10)
SET @today = CONVERT(VARCHAR(10), GETDATE(), 103)
SELECT @today
It returns 12/08/2014.
Can we modify the formula to make it return 12/08/14 instead?
Note: I use SQL Server 2008. It seems FORMAT() does not work with this version.
Thanks
Leon Lai
Are you looking for the below:
DECLARE @today varchar(10)
SET @today = CONVERT(VARCHAR(10), GETDATE(), 103)
SELECT Left(@today,6) + RIGHT(@today,2)
Note: I would suggest you to consider such formatting at application layer.
I'm surprised at your answer Latheesh:-
DECLARE @today varchar(8)
SET @today = CONVERT(VARCHAR(8), GETDATE(), 3)
SELECT @today
Surely this makes more sense?
Obvious, your code looks much better than me.
I dont do the formats in SQL Server , so am very poor in date format....:) .
Ah I see. I've always used a handy link: http://www.sql-server-helper.com/tips/date-formats.aspx
It's good for a quick reference if you need a specific date format. But as you pointed out, it's much more beneficial to keep to the SQL "canonical" format of YYYYMMDD or a datetime format, then display formatting at presentation layer. This preserves
the true ordering of dates.
EDIT:
Just as a side note Leon, I noticed you mentioned FORMAT() as a function. This is used in mySQL to format dates, the SQL Server equivalent of this is CONVERT().
Similar Messages
-
I want to know how to format a date in the way: 21 de junio de 2013 I mean I want to insert the word "de" between dd and mmmm and between mmmm and yyyy. Can anyone help me please?
Thanks in advanceHave a look at the util.printd() method.
-
How do I format a date string in ISO 8601 format?
Post Author: Perth
CA Forum: Formula
I am using a SaaS application, and uploading Crystal XI report templates to run using the application's reporting page. My custom date fields are stored using the ISO date format, and are made available as text strings in the form "yyyy-mm-ddThh:mm:ss" eg. "2007-10-09T00:00:00". The SaaS vendor say use a Crystal function. I have tried CDATE, DATEVALUE etc but these don't recognise the format as a valid date. I want to display this date as dd mmm yyyy. Any ideas?Post Author: Perth
CA Forum: Formula
I have found a solution from another forum and post it here to close this off.
It requires defining a "Report custom function". Use the formula workshop to create a function, giving it a name. Then paste this:
Function (stringVar v1)Date (ToNumber (Left (v1,4 )), ToNumber (Mid (v1, 6,2 )) , ToNumber (Mid (v1, 9,2 )) )
I can now format this date in the normal way as it is a date! -
When I populate several date fields from a database I find they have different formats (alpha month sometimes and not others for example). I'd like to force all dates from the database to be in mm/dd/yyyy format. I tried adding that as the formatString property, but that only seemed to work when the user enters the date, not if it is populated from a database.
I got this pseudocode from a friend who isn't around this week:
<DateValidator source="{dateInput}'
triggerevent=""
property="selected"
requiredFieldError="Date field is not selected"
id="myDateValidator"/>
//formatter for the date
private var valResult:ValidatorResultEvent
private function dateFormatting():void
valResult = myDateValidator.validate();
if(valResult.type == ValidatorEvent.Valid)
//do something
textInput.text = dateFormatter.format(textInput.text);
else
//do something
//formatter for the date
<DateFormatter id="dateFormatter" inputString="MM/DD/YYYY"/>
I would read that as:
1) set up a DateValidator with an input to be determined
2) set up a validation event
3) set up a function ...
4) set up a DateFormatter with the layout
I don't see how the function gets invoked anywhere. I also don't see how the specific date (and there are a lot of them) gets passed to the validator. It looks like a variable (dateInput) is set somewhere and bound to the validator, but I don't see where.
I'm assuming that once the function is called, the "valResults" gets the event that of the validation. And if that event is a valid date only needing formatting then the date formatter object is invoked. If it is not valid then a DateValidator error message pops up.
This process would be applied to five different components that are included in the system. Each may have one to 12 dates included in the component.
TIA,
JerryWould it be possible to make changes on the backend so the dates are delivered to Flex in the same format, then formatting on the Flex side is straightforward.
If this post answers your question or helps, please mark it as such.
Greg Lafrance - Flex 2 and 3 ACE certified
www.ChikaraDev.com
Flex Training and Support Services -
Windows Desktop Search 4.0 How do I Format the Date Column in the Results?
Is there a way to modify the date column in the Results pane of Windows Desktop Search 4.0?
It's running on a Windows 2003 Enterprise server.
I have users that need to modify files that arrived today and yesterday after 5:00 PM. The date column only displays the time on files with today's date. Is there some registry setting I can tweak to get this column to always show Date and Time?
Cordially,
RNHi,
For the Windows Desktop Search, i think you may ask in:
http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/home?forum=windowsdesktopsearchhelp
Regards.
Vivian Wang -
Hi, Can someone tell me how to simply format the date to this:
MON DD, YYYY
ThanksYou can use the SimpleDateFormat like:
java.text.DateFormat df = new java.text.SimpleDateFormat(format);where formar is a String like:
format= "dd/MM/yyyy";for a date like "07/06/2003"
You can use any format you want modifying the format using the following symbols:
Symbol Meaning Presentation Example
G era designator (Text) AD
y year (Number) 1996
M month in year (Text & Number) July & 07
d day in month (Number) 10
h hour in am/pm (1~12) (Number) 12
H hour in day (0~23) (Number) 0
m minute in hour (Number) 30
s second in minute (Number) 55
S millisecond (Number) 978
E day in week (Text) Tuesday
D day in year (Number) 189
F day of week in month (Number) 2 (2nd Wed in July)
w week in year (Number) 27
W week in month (Number) 2
a am/pm marker (Text) PM
k hour in day (1~24) (Number) 24
K hour in am/pm (0~11) (Number) 0
z time zone (Text) Pacific Standard Time
' escape for text (Delimiter)
'' single quote (Literal) '
Juan Carlos -
How can we give the Data Format (File Type ) in Runtime
Hi all,
How can we give the Data Format (File Type ) in Runtime for the following method,
cl_gui_frontend_services=>gui_download.
Thanks in advance
SriThere is a filetype parameter which you can set
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
* BIN_FILESIZE =
filename =
* FILETYPE = 'ASC'
* APPEND = SPACE
* WRITE_FIELD_SEPARATOR = SPACE
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = SPACE
* WRITE_LF = 'X'
* COL_SELECT = SPACE
* COL_SELECT_MASK = SPACE
* DAT_MODE = SPACE
* CONFIRM_OVERWRITE = SPACE
* NO_AUTH_CHECK = SPACE
* CODEPAGE = SPACE
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = SPACE
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* IMPORTING
* FILELENGTH =
changing
data_tab =
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* NO_BATCH = 2
* GUI_REFUSE_FILETRANSFER = 3
* INVALID_TYPE = 4
* NO_AUTHORITY = 5
* UNKNOWN_ERROR = 6
* HEADER_NOT_ALLOWED = 7
* SEPARATOR_NOT_ALLOWED = 8
* FILESIZE_NOT_ALLOWED = 9
* HEADER_TOO_LONG = 10
* DP_ERROR_CREATE = 11
* DP_ERROR_SEND = 12
* DP_ERROR_WRITE = 13
* UNKNOWN_DP_ERROR = 14
* ACCESS_DENIED = 15
* DP_OUT_OF_MEMORY = 16
* DISK_FULL = 17
* DP_TIMEOUT = 18
* FILE_NOT_FOUND = 19
* DATAPROVIDER_EXCEPTION = 20
* CONTROL_FLUSH_ERROR = 21
* NOT_SUPPORTED_BY_GUI = 22
* ERROR_NO_GUI = 23
* others = 24 -
How to print formated data/report on client's printer (Web Application)
Hi All
I want to print some formatted data/report ( it might be 1000 pages) on user's printer.
Application is web based
Technology used are Java - jsp - servlets
i want functionality like...
when user click on print button/link, data is fetched from server and all pages (it is formated data so i want alignment on page while printing) should be printed one after another.
Also printer selection dialog should displayed one time when user click on print button/link.
Questions:
1. How i will transfer all data to client (web browser) from the server ??
2. And how i can print that data on user's printer ??
There is requirement (or limitation) that I can not use applet for this purpose.
And also it is not fix that we must use java tech., we can use any othere tech. but condition is that it must support multiple platform (in short platform indipendant)
There is solution like ...
I can use window.print() function of DOM/JavaScript,
but it prints only one page which is displayed on browser.
I don't want to display any page. and want to print all pages.
if any one done or have idea then let me know.
Thanks in Adv.
Shailesh Koradiyathanks linxpda for reply,
we can use ActiveX component for windows platform for printing purpose, same way we can use platform specific component for printing... (for linux, unix, sun solaris etc...)
if it is possible then let me inform.
Thanks,
Shailesh Koradiya -
How to print formatted data / report on user's printer in Web Application
Hi All
I want to print some formatted data/report ( it might be 1000 pages) on user's printer.
application is web based and tech. used are Java - jsp - servlets
now prob. is ...
how i will transfer all data to client (web browser) from the server and how i can print that data on user's printer ...??
there is requirement that I can not use applet for this purpose.
if any one done or have idea then let me know.
thanks
Shailesh KoradiyaHi
Its simple, first of all break ur data in terms of pages. Write the logic in one JSP.
suppose i have jsp PrintReport.jsp , for page 1 url will PrintReport.jsp?page=0 ... so on
get the page parameter in JSP
String page="";
if(request.getParameter("page")!=null)
page=request.getParameter("page");
get the rowcount from the Result and assume records per page is 100
if u have 1000 rows then 10 pages u have to serve
StartRowNumber=page*recordsPerPage
EndRowNumber=StartRowNumber+recordsPerPage
Execute a SQL query , select * from table where rownum between
StartRowNumber and EndRowNumber
Provide google like pageNumbers in ur HTML page
ie 1 2 3 4 5 6 ..10
Regarding printing , Create HTML button called 'print' and add Javascript ' window.print()' on clicking it.
Hope it would solve ur problem
Cheers
Rajendra Bandi -
How can I change the date format in Reminders and in Notes?
How can I change the date format in both Notes and Reminders? Preference on Imac and Settings in IOS do not allow me to change the format in those 2 apps.
I Like to see 10oct rather than 10/10, as an example.pierre
I do not have Mavericks or iOS - but the first thing I would do is reset the defaults - I'll use Mavericks as an example
From If the wrong date or time is displayed in some apps on your Mac - Apple Support
OS X Yosemite and Mavericks
Open System Preferences.
From the View menu, choose Language & Region.
Click the Advanced button.
Click the Dates tab.
Click the Restore Defaults button.
Click the Times tab.
Click the Restore Defaults button.
Click OK.
Quit the app where you were seeing incorrect dates or times displayed.
Open the app again, and verify that the dates and times are now displayed correctly.
Then customize to taste - OS X Mavericks: Customize formats to display dates, times, and more
OS X Mavericks: Customize formats to display dates, times, and more
Change the language and formats used to display dates, times, numbers, and currencies in Finder windows, Mail, and other apps. For example, if the region for your Mac is set to United States, but the format language is set to French, then dates in Finder windows and email messages appear in French.
Choose Apple menu > System Preferences, then click Language & Region.
Choose a geographic region from the Region pop-up menu, to use the region’s date, time, number, and currency formats.
To customize the formats or change the language used to display them, click Advanced, then set options.
In the General pane, you can choose the language to use for showing dates, times, and numbers, and set formats for numbers, currency, and measurements.
In the Dates and Times panes, you can type in the Short, Medium, Long, and Full fields, and rearrange or delete elements. You can also drag new elements, such as Quarter or Milliseconds, into the fields.
When you’re done customizing formats, click OK.
The region name in Language & Region preferences now includes “Custom” to indicate you customized formats.
To undo all of your changes for a region, choose the region again from the Region pop-up menu. To undo your changes only to advanced options, click Advanced, click the pane where you want to undo your changes, then click Restore Defaults.
To change how time is shown in the menu bar, select the “Time format” checkbox in Language & Region preferences, or select the option in Date & Time preferences.
Here's the result AppleScript i use to grab the " 'Short Date' ' + ' 'Short Time' " to paste into download filenames - works good until I try to post it here - the colon " : " is a no-no but is fine in the Finder
Looks like iOS Settings are a bit less robust
- Date/Time formats are displayed according to 'tradition' of your region > http://help.apple.com/ipad/8/#/iPad245ed123
buenos tardes
ÇÇÇ -
How to update the default date format in OBIEE 11G.
Hi All,
How to change the default date format in OBIEE 11g from the MM/DD to DD/MM. Could anyone please help me out ASAP?
Thanks,
ArpanHi Arpan
OBIEE 11g is having " localedefinitions.xml " file at this Location C:\Oracle\Middleware\Oracle_BI1\bifoundation\web\display
in my case i installed at C:\Oracle\MIddleware.
so
1- Stop BI Server from EM
2- Navigate to this Location C:\Oracle\Middleware\Oracle_BI1\bifoundation\web\display. in your case oracle home will be different
3- take a backup of this file localedefinitions.xml "
4- modify it and save
5- bring BI Server up.
Regards
sher -
How to download the Dynamic data into PPT format
Hi Friends,
I have one doubt on WDJ. How to download the Dynamic data into PPT format. For Example Some Dynamic data is available in to View in that One Download Link or button available. Click on Download link or button download that data into PPT Format
Is it possible for WDJ. If possible please tell me.
Or
How to create Business Graphics in Web Dynpro Applications depening up on Excel Data and finally we can download the Business Graphics into powerpoint presentation.
Thank you,
Regards
Vijay Kalluri
Edited by: KalluriVijay on Mar 11, 2011 6:34 AMHi Govindu,
1. I have one doubt on WDJ. Click on either Submit Buttion or LinkToURL UI we can download the file that file having ppt formate(Text.PPT).
I am using NWDS Version: 7.0.09 and Java Version: JDK 1.6
2. is it possible to download the business Graphics in to the PPT by using Java DynPro
Regards
VijayK -
How to send ALV output data into Excel sheet format via Mail to the user?
Hi friends,
I have a doubt ie,
How to send ALV output data into Excel sheet format via Mail to the user?
regards
MoosaHi,
Provide the output internal table to the objbin in the below FM
Send Message
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = i_docdata
put_in_outbox = c_x
TABLES
packing_list = i_objpack
object_header = i_objhead
contents_bin = i_objbin
contents_txt = i_objtxt
receivers = i_reclist
and specify the document type
i_objpack-doc_type = 'XLS'.
and try.
Regards,
Nandha -
How to write the oracle data as XML format. (.XML file)
create or replace procedure pro(p_number )
is
cursor c1 is select *from emp where empno=p_number;
v_file utl_file.file_type;
begin
v_file := utl_file.fopen('dirc','filename.txt','w');
for i in c1 loop
utl_file.put_line(v_file,i.ename || i.empno ||i.job);
end loop;
closef(v_file);
end;
Now my client want instead of .txt file he need .xml files
File should contains xml tags. can any one help regarding this.. with one example.
How to write the oracle data as XML format. (.XML file)hi,
hope this example will do something....
SQL> select employee_id, first_name, last_name, phone_number
2 from employees where rownum < 6
EMPLOYEE_ID FIRST_NAME LAST_NAME PHONE_NUMBER
100 Steven King 515.123.4567
101 Neena Kochhar 515.123.4568
102 Lex De Haan 515.123.4569
103 Alexander Hunold 590.423.4567
104 Bruce Ernst 590.423.4568
SQL> select dbms_xmlgen.getxml('select employee_id, first_name,
2 last_name, phone_number from employees where rownum < 6') xml
3 from dual;
*<?xml version="1.0"?>*
*<ROWSET>*
*<ROW>*
*<EMPLOYEE_ID>100</EMPLOYEE_ID>*
*<FIRST_NAME>Steven</FIRST_NAME>*
*<LAST_NAME>King</LAST_NAME>*
*<PHONE_NUMBER>515.123.4567</PHONE_NUMBER>*
*</ROW>*
*<ROW>*
*<EMPLOYEE_ID>101</EMPLOYEE_ID>*
*<FIRST_NAME>Neena</FIRST_NAME>*
*<LAST_NAME>Kochhar</LAST_NAME>*
*<PHONE_NUMBER>515.123.4568</PHONE_NUMBER>*
*</ROW>*
*<ROW>*
*<EMPLOYEE_ID>102</EMPLOYEE_ID>*
*<FIRST_NAME>Lex</FIRST_NAME>*
*<LAST_NAME>De Haan</LAST_NAME>*
*<PHONE_NUMBER>515.123.4569</PHONE_NUMBER>*
*</ROW>*
*<ROW>*
*<EMPLOYEE_ID>103</EMPLOYEE_ID>*
*<FIRST_NAME>Alexander</FIRST_NAME>*
*<LAST_NAME>Hunold</LAST_NAME>*
*<PHONE_NUMBER>590.423.4567</PHONE_NUMBER>*
*</ROW>*
*<ROW>*
*<EMPLOYEE_ID>104</EMPLOYEE_ID>*
*<FIRST_NAME>Bruce</FIRST_NAME>*
*<LAST_NAME>Ernst</LAST_NAME>*
*<PHONE_NUMBER>590.423.4568</PHONE_NUMBER>*
*</ROW>*
*</ROWSET>*
ask if you want more assistance.
thanks. -
How to download the report data in xml format
Hi All,
how to download the report data (sql/interactive) in xml format...
Thanks,
VinothYou will want to do something like this:
http://spendolini.blogspot.com/2006/04/custom-export-to-csv.html
except customize it for xml.
hth,
John
Maybe you are looking for
-
How to load different modules in moduleLoader - some with other without unload?
Ok so I've read a lot about modules and I decided to build a site where I have a button bar menu and a single moduleLoader, where all of my pages are separate modules. Some of the modules will be preloaded with moduleManager technique so they will be
-
Create a Table in Visual Composer 7.0
Is there a way to create a custom table, as part of the model, where you can define some custom fileds, then have users add, delete or update those table fields from a form? Similar to how you would use MS Access? Thanks John
-
Is it possible to alter a Color's RGB value ?
I'd like the Color references I'm using to stay referring to the same object when I change the color values. So ideally I'd like to change the RGB values of these Colors, since making new Color objects is obviously not what I want. Neither Color nor
-
Command to log agent out/in on workstation?
(11.2.x) -- Is there a command to get the Zenworks agent to log out, and also one for logging in, at the Windows workstation? e.g. a command-line equivalent to right-clicking the icon in the system tray area & choosing "Logout" or "Login". I'm sure i
-
JAX-RPC Client - java.rmi.RemoteException:/getPort best practices
We are working on java webservices(JAX-RPC style) and while consuming Java WebService sometime getting 'Remote Exception' .I have generated client side code with weblogic ant task "clientgen". 1: Exception java.rmi.RemoteException: SOAPFaultException