Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 79303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:07:29+00:00 2026-05-10T21:07:29+00:00

i get this error {Method ‘System.DateTime ConvertTimeFromUtc(System.DateTime, System.TimeZoneInfo)’ has no supported translation to SQL.}

  • 0

i get this error

{'Method 'System.DateTime ConvertTimeFromUtc(System.DateTime, System.TimeZoneInfo)' has no supported translation to SQL.'}   

when i try to execute this linq to sql

var query = from p in db.Posts             let categories = GetCategoriesByPostId(p.PostId)             let comments = GetCommentsByPostId(p.PostId)             select new Subnus.MVC.Data.Model.Post             {                 Categories = new LazyList<Category>(categories),                 Comments = new LazyList<Comment>(comments),                 PostId = p.PostId,                 Slug = p.Slug,                 Title = p.Title,                 CreatedBy = p.CreatedBy,                 CreatedOn = TimeZoneInfo.ConvertTimeFromUtc(p.CreatedOn, TimeZoneInfo.FindSystemTimeZoneById('Romance Standard Time')),                 Body = p.Body             }; return query; 

is there another place i can convert the date to right format currently i have a macro i my _global.spark fil but that seems wrong

<macro name='DateAndTime' Date='DateTime'> # Date = TimeZoneInfo.ConvertTimeFromUtc(Date, TimeZoneInfo.FindSystemTimeZoneById('Romance Standard Time')); ${Date.ToString('MMMM d, yyyy')} at ${Date.ToString('hh:mm')} </macro> <macro name='Date' Date='DateTime'> # Date = TimeZoneInfo.ConvertTimeFromUtc(Date, TimeZoneInfo.FindSystemTimeZoneById('Romance Standard Time')); ${Date.ToString('MMMM d, yyyy')} </macro>  

Update: i now understand where the code does not work but when i remove it i get then same error for this code

 public IQueryable<Subnus.MVC.Data.Model.Comment> GetCommentsByPostId(int postId)     {         var query = from c in db.Comments                     where c.PostId == postId                     select new Subnus.MVC.Data.Model.Comment                     {                         Body = c.Body,                         EMail = c.EMail,                         Date = c.CreatedOn,                         WebSite = c.Website,                         Name = c.Name                     };          return query;     } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:07:29+00:00Added an answer on May 10, 2026 at 9:07 pm

    LINQ-to-SQL only translates a subset of operations – and it trying (and failing) to write ConvertTimeFromUtc as TSQL. Some operations have TSQL counterparts (dateadd/datediff/etc) – but not all. You might choose to do your projection (select) using the raw value, and only do the ConvertTimeFromUtc once you have the object in memory (via LINQ-to-Objects).

    For example – you could create the objects just using p.CreatedOn, then do the rest afterwards. Not ideal, but life. LINQ-to-Entities claims better translation options, but is significantly more complex. Depending on your scenario, LINQ-to-SQL also offers udf support, which sometimes lets you offload these things to the db – if there is a way of writing it as a udf – for example, you could write a method on the data-context and mark is as a composable function ([Function]), then something like:

     ...     CreatedOn = ctx.MapDate(p.CreatedOn)  .... 

    Which would then use the TSQL from [Function] – i.e. something like:

    ....     dbo.MapDate(t2.CreatedOn) .... 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 77k
  • Answers 77k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Dispose is protected on System.Xml.XmlWriter. You should use Close instead.… May 11, 2026 at 3:33 pm
  • added an answer It is worthwhile separating the MySQL v4/v5 upgrade from the… May 11, 2026 at 3:33 pm
  • added an answer Get your developers to read the free online Red-Bean Book.… May 11, 2026 at 3:33 pm

Related Questions

i get this error {Method 'System.DateTime ConvertTimeFromUtc(System.DateTime, System.TimeZoneInfo)' has no supported translation to SQL.}
I'm trying to use a Thread in a simple winform. I have a ListBox
I have a entity which has a list of Child1 objects. The mappings seem
i am working on a simple web app which has a user model and
I have a model, Thing, that has a has_many with ThingPhoto, using Paperclip to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.