HI,
I'm pretty new to MS SQL,
My problem is setting ....
=Format$(Date() ,"mm" & "/1/" & "YYYY")
(Which is from my MS ACCESS database)
as my default value in MS SQL. How can I do this since format() does
not seem to be a function that is in MS SQL. The above function works
great in MS ACCESS, but not in MS SQL.
thanks 4 22036
sql guy123 (st*****@hotmai l.com) writes: I'm pretty new to MS SQL,
My problem is setting ....
=Format$(Date( ),"mm" & "/1/" & "YYYY")
(Which is from my MS ACCESS database)
as my default value in MS SQL. How can I do this since format() does not seem to be a function that is in MS SQL. The above function works great in MS ACCESS, but not in MS SQL.
There are *huge* differences between Access and SQL Server. First of all
SQL Server is a server-only program, while in Access, you have a mixup
of client and database in the same package. But there are also big
differences between Access and SQL Server in the SQL dialect.
For formating dates, you use the convert function:
SELECT convert(varchar , getdate(), nnn)
where nnn is a format code, each format code giving a different format. And
there is no room for customer format. Look up the topic CAST and CONVERT in
Books Online to see the available format codes.
Best practice, though, is to return dates as is from SQL Server, and do
the formatting in the client, so the user's regional settings can be
taken into account.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx
I'm actually not really trying to format the date, but rather set the
default value of the column(field) to the first day of the month.
example: 1/1/2005, 2/1/2005, 3/1/2005 etc...
What is the best way to get the default value in MS SQL to be the first
day of the month?
try
=CONVERT(smalld atetime,DATENAM E(m, GETDATE()) + ' 1,' + DATENAME(yy,
GETDATE()))
HTH,
Stu This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jean |
last post by:
Hi,
I have a query that contains the following in the WHERE part of the
query:
WHERE....Format(IIf(nz()<>0,,
IIf(nz()<>0,,
IIf(nz()<>0,,
))),"0.0") AS Körperhöhe,....
|
by: ethoemmes |
last post by:
Hi
I am trying to use the below functions to return the month for a given
date. I want the month displayed as Jan for 01 so I wrapped the Month
function in the Format function.
Month: Format(Month(tblSalary!SalaryDate),"mmm") & " " &
Year(tblSalary!SalaryDate)
Unfortunately this is returning Jan 2005 no matter what date it is
|
by: MLH |
last post by:
Can the Format$ function be used to format 42397136 to "42,397,136" ?
|
by: KJ |
last post by:
Hello,
Why does this not work?
txtMoney.Text.Format("#,##0.00")
If I type 100 in txtMoney, it returns #,##0.00
I have never gotten the format function to work in .NET.
|
by: Steve Long |
last post by:
Hello,
I'm encountering a bug, or user error, with the Format function and I'm
wondering if someone can either straighten me out or confirm the bug.
I'm passing in a Date to the Format function and a style:
Dim dte As Date = Date.Parse("8/19/2005 1:06:00 PM")
Dim s As String = "mm/dd/yyyy"
Console.WriteLine(Format(dte, s))
| |
by: Lee |
last post by:
In VB6 you could use the format function to format strings using the @ and !
symbols. for example format("LEE", "!@@@@@@@@") would left align the string
"LEE" to the number of spaces allowed in the repeatings @'s. Has this
functionality disappeared in the format function for .NET, if so where has it
gone?
|
by: bob |
last post by:
In vb6 you could say s = Format(s, "!") to force text to upper case in
the format
function. I've searched the vb.net help system and can't find any help
on formatting text. There's plenty of help formatting numbers, dates,
and times, though.
Does the vb.net format function have a way to convert text to upper or
lower case?
Thanks.
|
by: thi |
last post by:
Hi,
Just wondering whether there is any filesize format function in c#? The
reason i ask because i want to display the file size just like windows e.g.
100 KB, 1MB, 1GB etc...
I am kind of hoping there is a method already built in c# as currently i
have to write a custom one and it looks like this:
private string formatsizekb(double dsize)
|
by: veer |
last post by:
Hi
i used the following format function in vb6.0 it works fine
Format(DTPFromDate & " 00:00:00", "dd/mm/yyyy HH:MM:SS AMPM")
but when i use same format function in vb.net it shows output like this
MM/dd/yyyy HH:MM:SS AMPM
please give some idea about vb.net format function
reGArds
|
by: Conan Kelly |
last post by:
Crossposted:
microsoft.public.dotnet.languages.vb
microsoft.public.sqlserver.integrationsvcs
Hello all,
In XL 2003's VBA, I could use the format function to change "11SEP2008" (a
string) to "11-SEP-2008" (another string) like so:
|
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...
| |
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,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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();...
|
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...
| |
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 we have to send another system
|
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...
| |