Cast and Convert functions in SQL Server Part 28



In this video we will learn, converting one data type to another using cast() and convert() functions. We will also learn how to use the style parameter, with convert() function. Finally we will look at a practical example of using CAST or CONVERT functions, along with group by. We will also talk about the differences between CAST and CONVERT functions and when to choose one over the other.

Text version of the video

Slides

All SQL Server Text Articles

All SQL Server Slides

All Dot Net and SQL Server Tutorials in English

All Dot Net and SQL Server Tutorials in Arabic

Nguồn: https://rumanoffsfinejewelry.com/

Xem thêm bài viết khác: https://rumanoffsfinejewelry.com/tong-hop/

  • Thank you, this was helpful !

    Mona Zabihian July 9, 2020 7:08 pm Reply
  • How to convert one date format into another, Ex to_date(column name, 'yyyy-mm-dd') , Column _nam format is yyyymmdd.

    suni2308 July 9, 2020 7:08 pm Reply
  • Thank you Kudvenkat, amazing videos on SQL. DO you have similar video's for SSAS and SSIS

    Neelam Saroy July 9, 2020 7:08 pm Reply
  • Thank you very much for the explanation. I'm always following your videos to learn and find the solution related to SQL question. In one of my sql query result, I'm getting the error Conversion failed when converting the nvarchar value '““““`'to data type int. However, due to number of columns and tables in my query, I'm not able to find the exact value which cautioning the issue. Can please explain how can we find such values with multiple join tables and many columns. Thank you.

    Niraj shah July 9, 2020 7:08 pm Reply
  • HI where can i get the DB you are working on.

    Nazia Jahan July 9, 2020 7:08 pm Reply
  • Venkat Can we use Rollup query as GroupBy Rollup(Registration Date as Date)

    MUNISH PRABHAKAR July 9, 2020 7:08 pm Reply
  • It could be also convert
    Convert (char(13),tablenameofdateofbirth,104)

    Amit Kumar Yadava July 9, 2020 7:08 pm Reply
  • how to convert mm to ft in

    Jeetendra Chandorkar July 9, 2020 7:08 pm Reply
  • Hello sir, same as u explained in video i tried. But, getting the same values in nvarchar also.

    stalin louis July 9, 2020 7:08 pm Reply
  • i have two column id and nane id 1 name salmankhan i want to split name like fname= salman and lname =khan into seprate column

    Durgesh Parlewar July 9, 2020 7:08 pm Reply
  • sir make video on performance of query ans SSIS

    Durgesh Parlewar July 9, 2020 7:08 pm Reply
  • HI BRO IF I EXECUTE THIS
    SELECT CAST('1993.06.19' AS nvarchar)
    IT IS STILL LIKE "1993.06.19"
    I AM USING SQL 2012
    BUT IN YOUR EXAMPLE IT WOULD BE LIKE JUNE 6 1993
    HOW DO I SOLVE THIS PROBLEM?

    Alish Safarli July 9, 2020 7:08 pm Reply
  • Thank you bro

    vinoth ganapathi July 9, 2020 7:08 pm Reply
  • Hi sir
    When I am converting Date to integer or decimal using cast and convert, it's reflecting the date value less than its actual value.
    Please suggest.

    D Shekar July 9, 2020 7:08 pm Reply
  • create procedure st_getShifts

    as

    select s.sh_id as 'ID',

    s.sh_name as 'Name',

    format(s.sh_fromTime,'hh:mm tt') as'From',

    format(s.sh_toTime,'hh:mm tt') as'TO',

    s.sh_number as 'Number'

    from shifts s
    error show WHEN EXUCUTE

    Msg 195, Level 15, State 10, Procedure st_getShifts, Line 49

    'format' is not a recognized built-in function name.

    HOW SOLVE PLS HELP ME

    jonti pass July 9, 2020 7:08 pm Reply
  • Very detailed…and very nice explanation

    Aditya Kumar Seth July 9, 2020 7:08 pm Reply
  • Thank you!

    Dmitriy Yudnikov July 9, 2020 7:08 pm Reply
  • perfect. Thanks a lot

    alireza nikoughadam July 9, 2020 7:08 pm Reply
  • how can i convert a video into a data in sql?

    Arjun Goyal July 9, 2020 7:08 pm Reply
  • It is very help ful video for the Learners but in the in version 2014 it does not work and I try with following Syntax and it works.
    SELECT ID, Name, DateOfBirth, CONVERT(VARCHAR(15), DateOfBirth,9) AS ConvertedDate FROM Employees
    Result:

    1 Sam 1980-12-30 Dec 30 1980

    2 Pam 1982-09-01 Sep 1 1982

    3 John 1985-08-22 Aug 22 1985

    4 Sara 1979-11-29 Nov 29 1979

    Champa Ghalley July 9, 2020 7:08 pm Reply
  • My date is stored in the varchar and I want to convert it to date type so that i can extract month and date from it. please help

    Utkarsh Pande July 9, 2020 7:08 pm Reply
  • please help

    Ramchandra Mishra July 9, 2020 7:08 pm Reply
  • Hello sir, how to solve this problem —–>The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

    Ramchandra Mishra July 9, 2020 7:08 pm Reply
  • I would a bit modify the title: "Best SQL Server tutorial ever – Part 28"

    Trzbne July 9, 2020 7:08 pm Reply
  • Love You Kudvenkat

    Programmers Heaven July 9, 2020 7:08 pm Reply
  • 4:43 => The important difference between Convert and Cast

    John Zhang, CFA July 9, 2020 7:08 pm Reply
  • You speak clearly.So easy to understand the concepts!
    Thanks.

    tanya sinha July 9, 2020 7:08 pm Reply
  • that was amazing , you really solved my problems. thanks a lot

    saad alkandari July 9, 2020 7:08 pm Reply
  • Write a query which returns the total number of registrations by Year?
    select cast(datepart(year,doj)as int)as 'DOJ',count(id) from tblDate
    group by cast(datepart(year,doj) as int)

    Suresh Molabanti July 9, 2020 7:08 pm Reply
  • Thanx! That's great ! It is very useful! You are great SQL teacher!

    Krzysztof S July 9, 2020 7:08 pm Reply
  • this videos are very helpful for beginners. definitely ill suggest my friends…
    thank you so much

    shiva kumar boorla July 9, 2020 7:08 pm Reply
  • This was very good…thank you! I need to learn the difference between nvar and var

    Tanner Tucker July 9, 2020 7:08 pm Reply
  • can anyone help how do we convert YYYYMMDD (int) to MM/DD/YYYY(datetime) ?

    Ian Simon July 9, 2020 7:08 pm Reply
  • This is the best SQL tutorials I have come across. I got trained from best of the professor from US based university but they are not as detailed as you in explanation.,,,,Kudos Mr.Venkat

    Sohan Yennu July 9, 2020 7:08 pm Reply
  • In 2005 SQL server how I to retrieve 'date' only from 'date time, data type

    sri lakshmi July 9, 2020 7:08 pm Reply
  • Awsome, I am now watching ur each video step by step….. This is really helpful for me… Thanks for ur video.

    Awadhesh Kumar Singh July 9, 2020 7:08 pm Reply
  • Very clear explanation!

    Keerthana Parthasarathy July 9, 2020 7:08 pm Reply
  • Sir My Cast and Convert function is not working..Can You please help me..Both functions is written same value which is inside Dateofbirth table..EG : = 1991-11-15 00:00:00.000 in Dateofbirth..& When i convert this it's showing Again 1991-11-15 00:00:00.000 in ConvertedDBO..Please Help me sir..

    Shashank Mohar July 9, 2020 7:08 pm Reply
  • I had made a table with column of data type datetime2 but neither CAST() nor Convert() worked with that column but when i changed it to datatype of datatime it worked ,, so is it just not working with datetime2 datatype ??

    Khalid Abdl-Monem Mekdad July 9, 2020 7:08 pm Reply
  • sir kindly help with tutorial 27.plz tell me a simple way of calculating age it is very complicated.

    Zeeshan Hamid July 9, 2020 7:08 pm Reply
  • Hi Venkat! what's the datatype for DateofBirth you used while creating tblemployees?

    Kirtee Bhattarai July 9, 2020 7:08 pm Reply
  • Revisit since I like it
    Thanks

    krismaly July 9, 2020 7:08 pm Reply
  • Venkat, thank you VERY much for providing all of this material free of charge. For those of us who are hands on type of learners, is the database(s) for these tutorials available to download?

    TheDemockery1 July 9, 2020 7:08 pm Reply
  • Hi Venkat…..Thanks a lot for these tutorials….I noticed that CAST and CONVERT does not work for  Datatype DATETIME2…is it correct?

    zubair siddique July 9, 2020 7:08 pm Reply
  • requsting to upload linq C# tutorials

    #Stuti# #Tehri# July 9, 2020 7:08 pm Reply

Leave a Reply

Your email address will not be published. Required fields are marked *