Date Format | T-SQL Code | Output |
Mon DD YYYY HH:MIAM (or PM) |
SELECT CONVERT(VARCHAR(20), GETDATE(), 100) | Feb 23 2014 3:00PM |
MM/DD/YY | SELECT CONVERT(VARCHAR(8), GETDATE(), 1) AS [MM/DD/YY] | 02/23/14 |
MM/DD/YYYY | SELECT CONVERT(VARCHAR(10), GETDATE(), 101) AS [MM/DD/YYYY] | 02/23/2014 |
YY.MM.DD | SELECT CONVERT(VARCHAR(8), GETDATE(), 2) AS [YY.MM.DD] | 14.02.23 |
YYYY.MM.DD | SELECT CONVERT(VARCHAR(10), GETDATE(), 102) AS [YYYY.MM.DD] | 2014.02.23 |
DD/MM/YY | SELECT CONVERT(VARCHAR(8), GETDATE(), 3) AS [DD/MM/YY] | 23/02/14 |
DD/MM/YYYY | SELECT CONVERT(VARCHAR(10), GETDATE(), 103) AS [DD/MM/YYYY] | 23/02/2014 |
DD.MM.YY | SELECT CONVERT(VARCHAR(8), GETDATE(), 4) AS [DD.MM.YY] | 23.02.14 |
DD.MM.YYYY | SELECT CONVERT(VARCHAR(10), GETDATE(), 104) AS [DD.MM.YYYY] | 23.02.2014 |
DD-MM-YY | SELECT CONVERT(VARCHAR(8), GETDATE(), 5) AS [DD-MM-YY] | 23-02-14 |
DD-MM-YYYY | SELECT CONVERT(VARCHAR(10), GETDATE(), 105) AS [DD-MM-YYYY] | 23-02-2014 |
DD Mon YY | SELECT CONVERT(VARCHAR(9), GETDATE(), 6) AS [DD MON YY] | 23 Feb 14 |
DD Mon YYYY | SELECT CONVERT(VARCHAR(11), GETDATE(), 106) AS [DD MON YYYY] | 23 Feb 2014 |
Mon DD, YY | SELECT CONVERT(VARCHAR(10), GETDATE(), 7) AS [Mon DD, YY] | Feb 23, 14 |
Mon DD, YYYY | SELECT CONVERT(VARCHAR(12), GETDATE(), 107) AS [Mon DD, YYYY] | Feb 23, 2014 |
HH:MM:SS | SELECT CONVERT(VARCHAR(8), GETDATE(), 108) | 05:15:10 |
Mon DD YYYY HH:MI:SS:MMMAM (or PM) | SELECT CONVERT(VARCHAR(26), GETDATE(), 109) | Feb 23 2014 10:15:10:214AM |
MM-DD-YY | SELECT CONVERT(VARCHAR(8), GETDATE(), 10) AS [MM-DD-YY] | 02-23-14 |
MM-DD-YYYY | SELECT CONVERT(VARCHAR(10), GETDATE(), 110) AS [MM-DD-YYYY] | 02-23-2014 |
YY/MM/DD | SELECT CONVERT(VARCHAR(8), GETDATE(), 11) AS [YY/MM/DD] | 14/02/23 |
YYYY/MM/DD | SELECT CONVERT(VARCHAR(10), GETDATE(), 111) AS [YYYY/MM/DD] | 2014/02/23 |
YYMMDD | SELECT CONVERT(VARCHAR(6), GETDATE(), 12) AS [YYMMDD] | 140223 |
YYYYMMDD | SELECT CONVERT(VARCHAR(8), GETDATE(), 112) AS [YYYYMMDD] | 20140223 |
DD Mon YYYY HH:MM:SS:MMM(24h) | SELECT CONVERT(VARCHAR(24), GETDATE(), 113) | 23 Feb 2014 11:30:25:100 |
HH:MI:SS:MMM(24H) | SELECT CONVERT(VARCHAR(12), GETDATE(), 114) AS [HH:MI:SS:MMM(24H)] | 10:15:20:211 |
YYYY-MM-DD HH:MI:SS(24h) | SELECT CONVERT(VARCHAR(19), GETDATE(), 120) | 2014-02-23 16:00:10 |
YYYY-MM-DD HH:MI:SS.MMM(24h) | SELECT CONVERT(VARCHAR(23), GETDATE(), 121) | 2014-02-23 08:15:25.120 |
YYYY-MM-DDTHH:MM:SS:MMM | SELECT CONVERT(VARCHAR(23), GETDATE(), 126) | 2014-02-23T10:25:30:120 |
DD Mon YYYY HH:MI:SS:MMMAM | SELECT CONVERT(VARCHAR(26), GETDATE(), 130) | 23 Feb 2014 10:25:30:120AM |
DD/MM/YYYY HH:MI:SS:MMMAM | SELECT CONVERT(VARCHAR(25), GETDATE(), 131) | 23/02/2014 10:25:30:120AM |
This is a blog where you are going to find tips or solution that are going to be helpful in the technology environment.
Thursday, June 26, 2014
SQL Date Format Examples
Wednesday, June 18, 2014
JQuery - Detect a button click
The following example shows how to detect a button click.
With JQuery detect when the document is ready
Load for the button by it's id
Call the Click event of the button
Make an empty function with the code to be executed when the click event happens
With JQuery detect when the document is ready
Load for the button by it's id
Call the Click event of the button
Make an empty function with the code to be executed when the click event happens
// Java Script Function $(document).ready(function () { $('#btn').click(function () { alert("The button was clicked."); }); }); Click this button:
Thursday, June 12, 2014
Steps to set startup page for debugging in asp.net mvc aplication
To set the start page in Visual Studio for a MVC application, follow the next steps:
- Got to Projects >>
Properties ... - Click the Web Tab
- Select the Specific Page radio button
- Type the URL in the Specific Page text box
Wednesday, June 11, 2014
How to get the last ID inserted in SQL
To get the last ID after an insertion you can use the @@Identity system function, if there was not insertion you will get a NULL value:
INSERT INTO People(First) VALUES ('Joseph');
SELECT ID FROM People WHERE ID = @@Identity;
You can also use the MAX function to get the last record inserted:
SELECT MAX(ID) AS ID FROM People
Another way to get it, is by the ident_current function:
SELECT ident_current(People) AS ID
Is it safe to delete files in the Windows Installer folder?
Over time the folder C:\Windows\Installer can grow a lot, many computers or laptops with small HD can have some problems.
The C:\Windows\Installer folder is really important because is where some applications uninstall files and folders are stored, if you delete the files you are not going to be able to uninstall correctly the applications.
Something you can do is backup this folder and when an application needs to be removed you can restore the files from the backup, the uninstall process should work just fine.
The C:\Windows\Installer folder is really important because is where some applications uninstall files and folders are stored, if you delete the files you are not going to be able to uninstall correctly the applications.
Something you can do is backup this folder and when an application needs to be removed you can restore the files from the backup, the uninstall process should work just fine.
Monday, June 9, 2014
ModelState.AddModelError to add a simple validation
Use ModelState.AddModelError to add a simple validation and make the ModelState.isValid with errors.
// Validation logic if (MyData.Email.Trim().Length == 0){ ModelState.AddModelError("Email", "Invalid Email"); return View(MyData); }
Tuesday, June 3, 2014
Using @Html.ActionLink as image link
If you need to serve image with the link using Razor, you can use HtmlHelpers like Html.ActionLink() to make it possible, this is how you can do it.
First define the style with the image:
Then use the HtmlHelper and add the style:
a.link_logo { background:url(/images/logo.jpg) no-repeat top left; width: 355px; height: 75px; display: block; text-indent: -9999px; /* In order to hide the text */ }
Then use the HtmlHelper and add the style:
// -------------------------------- @Html.ActionLink("Home", "Index", "Home", null, null, null, null, new { @class = "link_logo" }) // -------------------------------- @Html.ActionLink("Home", "Index", null, new { @class = "link_logo" }) //---------------------------------
Subscribe to:
Posts (Atom)